/* 半隐书院 · 内容导航 UI 样式库（水墨主题）
 * 浅色 = 宣纸：米白纸底 + 浓墨文字 + 朱砂点缀
 * 深色 = 夜墨：墨石底 + 纸白文字 + 亮朱砂点缀
 * 注：CSS 变量名保持兼容（--accent-cyan 现为朱砂红），页面内联样式无需改动
 */

:root,
[data-theme="dark"] {
  --bg-body: #141619;
  --bg-sidebar: #17191d;
  --bg-card: #1d2025;
  --bg-card-hover: #23262c;
  --bg-inset: #26292f;
  --bg-input: #1a1d22;
  --border-subtle: rgba(234, 230, 218, 0.09);
  --border-card: #2b2e35;
  --border-hover: #c8573f;

  --text-0: #eae6da;
  --text-1: #c6c0b2;
  --text-2: #98917f;
  --text-faint: #6e6a5e;

  --accent-cyan: #c8573f;
  --accent-cyan-hover: #d96a52;
  --accent-cyan-soft: rgba(200, 87, 63, 0.14);
  --accent-cyan-border: rgba(200, 87, 63, 0.35);

  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(200, 87, 63, 0.08);

  --grain-opacity: 0.07;
}

[data-theme="light"] {
  --bg-body: #fbfaf6;
  --bg-sidebar: #f5f3ec;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-inset: #f1eee4;
  --bg-input: #ffffff;
  --border-subtle: #e9e4d6;
  --border-card: #e4decd;
  --border-hover: #a83a2a;

  --text-0: #211d16;
  --text-1: #3b362b;
  --text-2: #6e6756;
  --text-faint: #9b937f;

  --accent-cyan: #a83a2a;
  --accent-cyan-hover: #8c2f21;
  --accent-cyan-soft: rgba(168, 58, 42, 0.09);
  --accent-cyan-border: rgba(168, 58, 42, 0.28);

  --shadow-card: 0 1px 3px rgba(59, 50, 32, 0.05), 0 6px 18px rgba(59, 50, 32, 0.06);
  --shadow-hover: 0 12px 32px rgba(59, 50, 32, 0.12), 0 2px 8px rgba(168, 58, 42, 0.06);

  --grain-opacity: 0.035;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  background-color: var(--bg-body);
  color: var(--text-0);
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
}

/* 宣纸纹理：细腻的灰度噪点覆盖全站，双主题皆宜 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
  background: var(--accent-cyan-soft);
  color: var(--accent-cyan);
}

/* 基础 Layout 工具类定义 */
.block {
  display: block !important;
}

.inline-block {
  display: inline-block !important;
}

.hidden {
  display: none !important;
}

.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-card);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* ---- App Shell 布局 ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  z-index: 2;
}

/* 桌面端 Sidebar */
.sidebar {
  width: 240px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  padding: 20px 16px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-0);
  padding: 4px 8px;
  margin-bottom: 16px;
}

.sidebar-brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* 夜墨主题下，Logo 墨笔需要一纸圆托底方能显现 */
[data-theme="dark"] .sidebar-brand-logo {
  background: radial-gradient(circle at 38% 32%, #f8f4ea 0%, #ece5d3 78%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  padding: 2px;
}

.sidebar-brand-text {
  font-family: "Ma Shan Zheng", "Kaiti SC", "KaiTi", "STKaiti", "Noto Serif SC", cursive;
  font-size: 23px;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.sidebar-brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  margin-left: 2px;
  letter-spacing: 0.12em;
}

.sidebar-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-card) 18%, var(--border-card) 82%, transparent);
  margin: 12px 0 16px 0;
}

.side-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.side-group {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--text-faint);
  padding: 12px 10px 4px 10px;
  text-transform: uppercase;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-1);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

.side-link:hover {
  background-color: var(--bg-inset);
  color: var(--text-0);
}

.side-link-active {
  background-color: var(--accent-cyan-soft);
  color: var(--accent-cyan) !important;
  font-weight: 600;
}

.side-link-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background-color: var(--accent-cyan);
}

.side-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 主题切换器 */
.theme-toggle {
  display: flex;
  background-color: var(--bg-inset);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.theme-toggle-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.theme-toggle-btn:hover {
  color: var(--text-0);
}

.theme-toggle-btn.is-active {
  background-color: var(--bg-card);
  color: var(--accent-cyan);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.sidebar-filing {
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: none;
  text-align: center;
  transition: color 0.15s ease;
  letter-spacing: 0.06em;
}

.sidebar-filing:hover {
  color: var(--text-2);
}

/* 主内容区域 */
.app-main {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
  padding: 32px 48px 60px 48px;
  width: calc(100% - 240px);
  max-width: none;
}

/* 移动端 Topbar & Tabbar */
.m-topbar {
  display: none;
}

.m-tabbar {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .app-main {
    margin-left: 0;
    width: 100%;
    padding: 16px 16px 80px 16px;
  }

  .m-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
  }

  .m-tabbar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 56px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    padding: 4px 0;
  }

  .m-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
  }

  .m-tab-active {
    color: var(--accent-cyan);
    font-weight: 600;
  }
}

/* ---- 通用卡片样式 ---- */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.card-hover {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent-cyan-border);
}

/* ---- 英文眉题（配朱砂小印） ---- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 1.5px;
  background-color: var(--accent-cyan);
  opacity: 0.9;
  flex-shrink: 0;
}

/* ---- Chips 胶囊筛选栏 ---- */
.m-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.m-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid var(--border-card);
  background-color: var(--bg-card);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.m-chip:hover {
  border-color: var(--accent-cyan);
  color: var(--text-0);
}

.m-chip.is-active {
  background-color: var(--accent-cyan-soft);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  font-weight: 600;
}

/* ---- 圆形缩写徽章（水墨传统色，由 JS 按名取色） ---- */
.avatar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  color: #f7f2e6;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.18);
}

.avatar-badge-sm {
  width: 2rem;
  height: 2rem;
  font-size: 11px;
}

/* ---- Topic Card 独有组件样式 ---- */
.topic-card {
  display: block;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  margin-bottom: 12px;
  transition: all 0.2s ease;
  width: 100%;
}

.topic-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.topic-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-0);
  margin: 0;
  line-height: 1.5;
  flex: 1;
}

.topic-card-date {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  padding-top: 2px;
}

.topic-card-digest {
  font-size: 13px;
  color: var(--text-2);
  margin: 0 0 12px 0;
  line-height: 1.6;
}

.topic-card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-faint);
  flex-wrap: wrap;
}

.topic-card-stat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.topic-card-divider {
  color: var(--border-subtle);
}

.topic-card-company {
  color: var(--text-2);
}

.topic-card-owner {
  margin-left: auto;
  color: var(--text-faint);
}

/* 精华徽章：白文印章风（朱砂底、宣纸字） */
.badge-digest {
  font-size: 11px;
  background: var(--accent-cyan);
  color: #fbf6ea;
  border: 1px solid var(--accent-cyan);
  padding: 1px 7px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.1em;
  box-shadow: 0 1px 2px rgba(140, 47, 33, 0.28);
}

.badge-audio {
  font-size: 11px;
  background: var(--bg-inset);
  color: var(--text-2);
  border: 1px solid var(--border-subtle);
  padding: 1px 7px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* ---- 时间线 ( Timeline ) ---- */
.timeline-container {
  position: relative;
  padding-left: 28px;
  border-left: 2px solid var(--border-subtle);
  margin-left: 8px;
  margin-top: 16px;
  width: 100%;
  max-width: none;
}

.timeline-item {
  position: relative;
  margin-bottom: 16px;
  width: 100%;
}

.timeline-dot {
  position: absolute;
  left: -37px;
  top: 18px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  background-color: var(--bg-body);
  box-shadow: 0 0 0 4px var(--bg-body);
  z-index: 2;
}

/* ---- 搜索框 ---- */
.search-box-wrap {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  height: 46px;
  padding-left: 44px;
  padding-right: 16px;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background-color: var(--bg-input);
  color: var(--text-0);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.search-input::placeholder {
  color: var(--text-faint);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-soft);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  pointer-events: none;
}

/* ---- 访问口令验证 Modal ---- */
html.auth-locked .app-shell {
  display: none !important;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background-color: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: var(--shadow-hover);
  text-align: center;
  animation: authFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-badge-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--accent-cyan-soft);
  border: 1px solid var(--accent-cyan-border);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-0);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0 0 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  font-size: 15px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  color: var(--text-0);
  outline: none;
  text-align: center;
  letter-spacing: 2px;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.auth-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-soft);
}

.auth-btn {
  height: 44px;
  width: 100%;
  border-radius: 10px;
  background: var(--accent-cyan);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  font-family: inherit;
}

.auth-btn:hover {
  background: var(--accent-cyan-hover);
}

.auth-btn:active {
  transform: scale(0.98);
}

.auth-error-msg {
  font-size: 12px;
  color: #dc2626;
  margin-top: 8px;
  min-height: 18px;
}

.auth-shake {
  animation: authShake 0.4s ease-in-out;
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.auth-status-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
}

.auth-logout-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.auth-logout-btn:hover {
  color: var(--accent-cyan);
}

