/* ============================================================
 * Circle 社区风格个人网站 —— 全站样式
 * 设计规格参照 Circle.so 社区版式
 * ============================================================ */

:root {
  --bg: #f7f9fa;              /* 页面底色 */
  --surface: #ffffff;         /* 卡片/导航底色 */
  --border: #e4e7eb;          /* 通用边框 */
  --border-strong: #717680;   /* 强边框（登录按钮） */
  --text: #3b3b3b;            /* 正文 */
  --text-secondary: #42474d;  /* 次级文字 */
  --text-muted: #717680;      /* 弱化文字 */
  --heading: #19283a;         /* 标题 */
  --dark: #2b2e33;            /* 黑色按钮/激活胶囊 */
  --hover: #f0f2f4;           /* 悬停底色 */
  --active-pill: #eceff1;     /* 导航选中胶囊 */
  --side-text: #545861;       /* 侧边栏文字（标题与菜单项统一） */
  --side-hover: #f0f3f5;      /* 侧边栏悬停底色 */
  --side-hover-2: #e3e7ea;    /* 侧边栏悬停时小按钮的二级底色 */
  --title: #191b1f;           /* 卡片标题/筛选标签文字 */
  --scroll-thumb: #c9ced6;    /* 滚动条 */
  --scroll-thumb-hover: #aab1ba;
  --brand: #506cf0;           /* 品牌色 */
  --like: #e02424;            /* 点赞红 */
  --nav-h: 64px;
  --sidebar-w: 281px;
  --radius-card: 12px;
  --shadow-pop: 0 10px 38px -10px rgba(22, 23, 24, .35), 0 10px 20px -15px rgba(22, 23, 24, .2);
  --font: Inter, "InterVariable", system-ui, -apple-system, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif,
          "Apple Color Emoji", "Segoe UI Emoji";
  color-scheme: light;
}

/* ---------- 暗黑模式 ---------- */
:root[data-theme="dark"] {
  --bg: #17191c;
  --surface: #212327;
  --border: #33373d;
  --border-strong: #6c7280;
  --text: #c9cdd3;
  --text-secondary: #b3b8bf;
  --text-muted: #8b919a;
  --heading: #e8eaed;
  --hover: #2b2f34;
  --active-pill: #33373d;
  --side-text: #a9afb8;
  --side-hover: #2b2f34;
  --side-hover-2: #3a3f46;
  --title: #e8eaed;
  --scroll-thumb: #4a4f57;
  --scroll-thumb-hover: #5d636c;
  color-scheme: dark;
}
:root[data-theme="dark"] .side-item.is-active { background: #43484f; color: #fff; }
:root[data-theme="dark"] .btn--dark {
  background: #e8eaed; border-color: #e8eaed; color: #17191c;
}
:root[data-theme="dark"] .btn--dark:hover { background: #ffffff; }
:root[data-theme="dark"] .badge-admin { background: #e8eaed; color: #17191c; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

/* 应用式布局：页面本身不滚动，侧边栏和主内容各自独立滚动（与 Circle 一致） */
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#topnav { flex-shrink: 0; }

/* 细滚动条样式 */
.sidebar, .page {
  scrollbar-width: thin;
  scrollbar-color: #c9ced6 transparent;
}
.sidebar::-webkit-scrollbar, .page::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track, .page::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb, .page::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 9999px;
}
.sidebar::-webkit-scrollbar-thumb:hover, .page::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* chevron 图标通用尺寸 */
.chev-icon { width: 16px; height: 16px; flex-shrink: 0; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; }

/* ============================ 顶部导航 ============================ */
.topnav {
  position: relative; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 16px;
  padding: 8px 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topnav__logo {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0;
  font-weight: 800; font-size: 15px; letter-spacing: .04em;
  color: var(--heading); white-space: nowrap;
}
.topnav__logo .logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  font-size: 19px;
  background: linear-gradient(135deg, #506cf0, #9333ea);
  color: #fff;
}
.topnav__logo .logo-mark--img {
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--border);
}

/* Logo 旁的下拉按钮与菜单 */
.brand-wrap { position: relative; display: flex; align-items: center; gap: 2px; }
.brand-chev {
  display: grid; place-items: center;
  background: none; border: 0;
  padding: 8px 6px; border-radius: 8px;
  color: var(--text-muted);
}
.brand-chev:hover { background: var(--hover); color: var(--heading); }
.brand-menu { left: 0; right: auto; top: calc(100% + 6px); min-width: 232px; }
.more-menu a { display: flex; align-items: center; gap: 10px; }
.more-menu .menu-icon {
  display: grid; place-items: center;
  width: 20px; height: 20px; color: var(--text-secondary);
}
.more-menu .menu-icon svg { width: 19px; height: 19px; }

.topnav__menu {
  display: flex; align-items: center; gap: 4px;
  margin: 0 auto;
}
.topnav__menu a, .topnav__menu .more-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 9999px; border: 0;
  background: transparent;
  font-size: 15px; color: var(--text-secondary);
  white-space: nowrap;
}
.topnav__menu a:hover, .topnav__menu .more-btn:hover { background: var(--hover); }
.topnav__menu a.is-active { background: var(--active-pill); color: var(--heading); font-weight: 500; }
.topnav__menu .more-btn .chev-icon { width: 14px; height: 14px; }

.more-wrap { position: relative; }
.more-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 208px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-pop);
  display: none; flex-direction: column;
}
.more-menu.is-open { display: flex; }
.more-menu a {
  padding: 10px 12px; border-radius: 8px;
  font-size: 15px; color: var(--text-secondary);
}
.more-menu a:hover { background: var(--hover); }

.topnav__right { display: flex; align-items: center; gap: 12px; }

.search-btn {
  display: flex; align-items: center; gap: 8px;
  height: 40px; min-width: 128px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 9999px;
  background: var(--surface);
  font-size: 14px; color: var(--text-muted);
}
.search-btn:hover { border-color: var(--scroll-thumb); }

.topnav__divider { width: 1px; height: 24px; background: var(--border); }

.btn { border-radius: 9999px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn--outline {
  padding: 8px 24px; background: var(--surface);
  border: 1px solid var(--border-strong); color: var(--heading);
}
.btn--outline:hover { background: var(--hover); }
.btn--dark {
  padding: 9px 25px; background: var(--dark);
  border: 1px solid var(--dark); color: #fff;
}
.btn--dark:hover { background: #16181b; }

.hamburger {
  display: none;
  background: none; border: 0; font-size: 22px; color: var(--heading);
  padding: 6px 10px;
}

/* ============================ 整体布局 ============================ */
.shell { display: flex; flex: 1; min-height: 0; }

/* ============================ 左侧边栏 ============================ */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px 32px;
  overflow-y: auto;
}

.side-item {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 6px 16px;
  border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--side-text);
  line-height: 1.5;
  white-space: nowrap;
}
.side-item:hover { background: var(--side-hover); }
.side-item.is-active { background: var(--dark); color: #fff; }
.side-item .side-item__label { overflow: hidden; text-overflow: ellipsis; }
.side-item .side-item__icon { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.side-item .side-item__icon--lock { color: var(--text-muted); display: inline-flex; justify-content: center; }
.side-item.is-active .side-item__icon--lock { color: #cfd3d9; }
.side-item .social-icon { width: 18px; height: 18px; display: block; margin: 0 auto; }
:root[data-theme="dark"] .social-icon--x .bg { fill: #fff; }
:root[data-theme="dark"] .social-icon--x .glyph { fill: #000; }

.side-group { margin-top: 24px; }
.side-group__title {
  display: flex; align-items: center; gap: 4px;
  width: 100%; padding: 6px 16px; margin-bottom: 4px;
  border-radius: 8px;
  background: none; border: 0; text-align: left;
  font-size: 14px; font-weight: 600; color: var(--side-text);
  transition: background-color .2s ease;
}
.side-group__title:hover { background: var(--side-hover); }
.side-group__title .caret {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 4px;
  color: var(--side-text);
  opacity: 0;
  transition: transform .15s ease, opacity .15s ease;
}
.side-group__title .caret .chev-icon { width: 15px; height: 15px; }
.side-group__title .caret:hover { background: var(--side-hover-2); }
.side-group:hover .caret { opacity: 1; }   /* 悬停整个分组区域时出现箭头 */
.side-group__kebab {
  margin-left: auto;
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 4px;
  color: var(--side-text);
  opacity: 0;
  transition: opacity .15s ease;
}
.side-group__kebab svg { width: 15px; height: 15px; }
.side-group__kebab:hover { background: var(--side-hover-2); }
.side-group:hover .side-group__kebab { opacity: 1; }
.side-group.is-collapsed .caret { transform: rotate(-90deg); opacity: 1; }
.side-group.is-collapsed .side-group__items { display: none; }

.side-links__title {
  padding: 6px 16px; margin-bottom: 4px;
  font-size: 14px; font-weight: 600; color: var(--side-text);
}

/* ============================ 主区域 ============================ */
.page {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}

/* 头部栏在内容滚动容器内部吸顶（与 Circle 一致） */
.page-header {
  position: sticky; top: 0; z-index: 20;
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  min-height: 64px; padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.page-header__right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.latest-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 6px 10px; border-radius: 8px;
  font-size: 15px; color: var(--text-secondary);
}
.latest-btn:hover { background: var(--hover); }
.latest-btn .chev-icon { width: 14px; height: 14px; }
.facepile { display: flex; align-items: center; }
.face {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--surface);
  display: grid; place-items: center;
  font-size: 14px; margin-left: -8px;
}
.face:first-child { margin-left: 0; }
.face--count { background: var(--active-pill); color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--heading); }
.page-header .page-header__emoji { font-size: 20px; }
.page-header .back-link {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; color: #545861;
}
.page-header .back-link:hover { color: var(--heading); }

.page-body { padding: 24px 28px 64px; }

/* ---------- 筛选标签 ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.pill {
  padding: 8px 16px;
  border: 1px solid var(--border); border-radius: 9999px;
  background: var(--surface);
  font-size: 14px; color: var(--title);
}
.pill:hover { border-color: var(--scroll-thumb); }
.pill.is-active { border-color: var(--border-strong); }

/* ---------- 帖子卡片流 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.post-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.post-card__cover {
  position: relative; display: block;
  aspect-ratio: 2 / 1;
}
.post-card__cover .cover-ph {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-size: 44px;
}
.post-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.post-card__avatar {
  position: absolute; left: 20px; bottom: -20px;
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid var(--surface);
  display: grid; place-items: center;
  font-size: 20px;
  background: #ffe9d6;
  z-index: 2;
  overflow: hidden;
}
.post-card__avatar img, .author-row__avatar img {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.post-card__body { padding: 30px 20px 14px; flex: 1; }
.post-card__title {
  font-size: 16px; font-weight: 600; line-height: 1.3;
  color: var(--title);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card__title:hover { text-decoration: underline; }
.post-card__meta { margin-top: 8px; font-size: 14px; color: var(--text-muted); }

.post-card__footer {
  display: flex; align-items: center; gap: 22px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.icon-btn {
  display: flex; align-items: center; gap: 7px;
  background: none; border: 0;
  font-size: 14px; color: var(--text-muted);
}
.icon-btn:hover { color: var(--heading); }
.icon-btn.is-liked { color: var(--like); }
.icon-btn svg { width: 19px; height: 19px; }

.feed-empty {
  padding: 60px 0; text-align: center;
  color: var(--text-muted); font-size: 15px;
}

/* ============================ 帖子详情页 ============================ */
.post-detail-wrap {
  display: flex; justify-content: center;
  padding: 32px 24px 80px;
}
.post-detail {
  width: 100%; max-width: 672px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.post-detail__hero { aspect-ratio: 2 / 1; }
.post-detail__hero .cover-ph {
  width: 100%; height: 100%;
  display: grid; place-items: center; font-size: 72px;
}
.post-detail__inner { padding: 28px 32px 36px; }

.post-detail__titlebar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.post-detail__titlebar h1 {
  font-size: 26px; font-weight: 700; line-height: 1.35; color: var(--heading);
}
.share-btn {
  background: none; border: 0;
  font-size: 15px; color: var(--text-muted); padding-top: 6px;
}
.share-btn:hover { color: var(--heading); }

.author-row { display: flex; align-items: center; gap: 12px; margin: 20px 0 24px; }
.author-row__avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 20px;
  background: #ffe9d6;
  overflow: hidden;
  flex-shrink: 0;
}
.author-row__name {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; color: var(--heading);
}
.badge-admin {
  padding: 2px 8px; border-radius: 9999px;
  background: var(--dark); color: #fff;
  font-size: 11px; font-weight: 600;
}
.author-row__date { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.author-row__title { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.post-detail__content p {
  font-size: 17px; line-height: 1.85; margin-bottom: 18px;
}

.post-detail__actions {
  display: flex; gap: 24px;
  border-top: 1px solid var(--border);
  margin-top: 8px; padding-top: 18px;
}

.comment-gate {
  margin-top: 24px; padding: 16px;
  border: 1px solid var(--border); border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--text-muted); font-size: 15px;
}

/* ============================ 「从这开始」页 ============================ */
.start-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 316px;
  gap: 24px; align-items: start;
}

.start-post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 32px 36px;
}
.start-post__titlebar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.start-post__titlebar h2 { font-size: 24px; font-weight: 700; color: var(--heading); }
.start-post h3 {
  font-size: 19px; font-weight: 700; color: var(--heading);
  margin: 26px 0 14px;
}
.rule-line {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 16px; line-height: 1.7; margin-bottom: 14px;
}
.rule-line .rule-icon { flex-shrink: 0; }

.pinned-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
}
.pinned-card h3 { font-size: 17px; font-weight: 700; color: var(--heading); margin-bottom: 16px; }
.pinned-card li { margin-bottom: 14px; }
.pinned-card a { font-size: 15px; color: var(--text-secondary); }
.pinned-card a:hover { color: var(--heading); text-decoration: underline; }

/* ============================ 课程页 ============================ */
.courses-body { padding: 24px 36px 80px; }

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  max-width: 1180px;
  gap: 24px;
}

.course-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.course-card__cover { aspect-ratio: 16 / 9; padding: 12px; }
.course-card__cover .cover-ph {
  width: 100%; height: 100%;
  display: grid; place-items: center; font-size: 44px;
  border-radius: 8px;
}
.course-card__body { padding: 14px 20px 10px; flex: 1; }
.course-card__title { font-size: 16px; font-weight: 600; color: var(--heading); line-height: 1.4; }
.course-card__group { margin-top: 8px; font-size: 14px; color: var(--text-muted); }
.course-card__footer { padding: 14px 20px 18px; }
.course-lock {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; color: var(--text-secondary);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.enroll-btn {
  width: 100%; padding: 10px 0;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; font-weight: 500; color: var(--heading);
}
.enroll-btn:hover { background: var(--hover); }

/* ============================ 搜索遮罩 ============================ */
.search-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(25, 40, 58, .4);
  display: none; justify-content: center; align-items: flex-start;
  padding: 96px 16px 0;
}
.search-overlay.is-open { display: flex; }
.search-panel {
  width: 100%; max-width: 640px;
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.search-panel input {
  width: 100%; padding: 18px 22px;
  border: 0; outline: 0;
  font-size: 17px; font-family: inherit; color: var(--heading);
  border-bottom: 1px solid var(--border);
}
.search-results { max-height: 380px; overflow-y: auto; padding: 8px; }
.search-results a {
  display: block; padding: 12px 14px; border-radius: 10px;
  font-size: 15px; color: var(--text-secondary);
}
.search-results a:hover { background: var(--hover); }
.search-results .search-hint { padding: 18px 14px; color: var(--text-muted); font-size: 14px; }

/* ============================ 会员提示弹窗 ============================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(25, 40, 58, .4);
  display: none; place-items: center; padding: 16px;
}
.modal-overlay.is-open { display: grid; }
.modal {
  width: 100%; max-width: 400px;
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-pop);
  padding: 32px 28px; text-align: center;
}
.modal .modal__emoji { font-size: 44px; }
.modal h3 { font-size: 19px; color: var(--heading); margin: 14px 0 8px; }
.modal p { font-size: 15px; color: var(--text-muted); line-height: 1.6; margin-bottom: 22px; }
.modal .btn--dark { width: 100%; padding: 11px 0; }

/* ============================ 响应式 ============================ */
@media (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .start-layout { grid-template-columns: 1fr; }
  .topnav { padding: 8px 16px; }
}

@media (max-width: 820px) {
  .topnav__menu { display: none; }
  .search-btn { min-width: 0; }
  .search-btn .search-btn__label { display: none; }
  .btn--outline { display: none; }
  .hamburger { display: block; }

  .sidebar {
    position: fixed; left: 0; top: var(--nav-h); z-index: 150;
    height: calc(100vh - var(--nav-h));
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-pop); }

  .card-grid { grid-template-columns: 1fr; }
  .page-body { padding: 20px 16px 56px; }
  .courses-body { padding: 20px 16px 56px; }
  .post-detail-wrap { padding: 20px 12px 56px; }
  .post-detail__inner { padding: 22px 20px 28px; }
  .post-detail__titlebar h1 { font-size: 22px; }
}
