/* Core Palette Tokens - Refined Editorial & Financial Archive Theme */
:root {
  --ink: #141d19;
  --ink-soft: #2e3a35;
  --ink-light: #47544e;
  --muted: #6e7a73;
  --muted-light: #9aa69f;
  
  --paper: #fbfdf9;
  --paper-soft: #f1f5ef;
  --canvas: #e8eee8;
  --surface-card: #ffffff;
  
  --line: rgba(20, 29, 25, 0.08);
  --line-strong: rgba(20, 29, 25, 0.15);
  --line-focus: rgba(200, 75, 59, 0.45);
  
  /* Expressive Accent Tokens */
  --coral: #c84b3b;
  --coral-hover: #b33e2f;
  --coral-soft: #faece9;
  --coral-glow: rgba(200, 75, 59, 0.22);
  --evidence: #c94b56;
  --evidence-soft: rgba(201, 75, 86, 0.10);
  
  --teal: #087e78;
  --teal-hover: #066964;
  --teal-soft: #e2f3f0;
  
  --gold: #b8862d;
  --gold-soft: #faf3e2;
  --web: #4068a7;
  
  --white: #ffffff;
  
  /* Layered Shadows */
  --shadow-xs: 0 1px 2px rgba(20, 29, 25, 0.04);
  --shadow-sm: 0 2px 6px rgba(20, 29, 25, 0.05);
  --shadow-md: 0 8px 24px -4px rgba(20, 29, 25, 0.08), 0 2px 6px rgba(20, 29, 25, 0.03);
  --shadow-lg: 0 18px 40px -6px rgba(20, 29, 25, 0.12), 0 6px 12px rgba(20, 29, 25, 0.04);
  --shadow-popover: 0 22px 48px -8px rgba(10, 18, 14, 0.28), 0 8px 16px rgba(10, 18, 14, 0.08);
  
  /* Radiuses */
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  /* Transitions */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 140ms;
  --duration-normal: 220ms;
  
  color-scheme: light;

  /* User Reading Preferences (Dynamic) */
  --reading-font-size: 16px;
  --reading-line-height: 1.8;
  --reading-max-width: 780px;
  --reading-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --reading-paragraph-gap: 16px;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(20, 29, 25, 0.2);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: rgba(20, 29, 25, 0.35); }

/* ==========================================================================
   App Shell Layout: Sidebar (360px Fixed) + Workspace (Fluid)
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  transition: grid-template-columns 0.2s ease;
}

body:not([data-auth="authenticated"]) .app-shell {
  display: none;
}

@media (min-width: 1280px) {
  .app-shell.ai-panel-active {
    grid-template-columns: 320px minmax(0, 1fr) 420px;
  }
}

@media (min-width: 1600px) {
  .app-shell.ai-panel-active {
    grid-template-columns: 340px minmax(0, 1fr) 460px;
  }
}

/* ==========================================================================
   Sidebar: Deep Ink Editorial Theme + Embedded Mini Calendar
   ========================================================================== */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px 18px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #131b18;
  color: #eff3ec;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 20;
}

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

.brand-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(246, 215, 183, 0.4);
  object-fit: cover;
  box-shadow: 0 0 14px rgba(246, 215, 183, 0.12);
  background: #000000;
}

.brand-title {
  margin: 0;
  font-family: "Georgia", "Noto Serif SC", "Source Han Serif SC", serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f5f8f3;
}

.account-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #9cb0a4;
  font-size: 11px;
}

.account-line a {
  color: #f0b5a5;
  font-weight: 500;
  transition: color var(--duration-fast) ease;
}
.account-line a:hover { color: #ffd6cb; text-decoration: underline; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 14px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-item strong {
  display: block;
  color: #ffffff;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-item span {
  display: block;
  margin-top: 3px;
  color: #8da094;
  font-size: 10.5px;
}

/* ==========================================================================
   Sidebar Embedded Calendar
   ========================================================================== */
.sidebar-calendar-section {
  margin-top: 16px;
  padding: 14px 12px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}

.sidebar-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.month-selector-wrapper {
  position: relative;
  min-width: 0;
}

.month-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: #f5f8f3;
  cursor: pointer;
  text-align: left;
  transition: opacity var(--duration-fast) ease;
}

.month-title-btn:hover { opacity: 0.85; }

.month-title-btn h2 {
  margin: 0;
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.dropdown-chevron {
  color: var(--coral);
  font-size: 13px;
  transition: transform var(--duration-normal) var(--ease-spring);
}

.month-title-btn[aria-expanded="true"] .dropdown-chevron {
  transform: rotate(180deg);
}

.month-nav-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cal-nav-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  color: #dbe4dc;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: all var(--duration-fast) ease;
}

.cal-nav-btn.text-mode {
  font-size: 11px;
  font-weight: 600;
}

.cal-nav-btn:hover:not(:disabled) {
  background: var(--coral);
  border-color: var(--coral);
  color: #ffffff;
}

.cal-nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Calendar Legend */
.sidebar-calendar-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 10px;
  color: #8da094;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.legend-dot.opus { color: var(--coral); font-size: 9px; }
.legend-dot.video { color: var(--teal); font-size: 8px; }
.legend-dot.other { color: var(--gold); font-size: 8px; }

/* Weekday Row */
.sidebar-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: #7f9185;
}
.sidebar-weekday-row .weekend { color: #e5877b; }

/* Calendar Grid & Day Cells */
.sidebar-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.sidebar-day-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  box-sizing: border-box;
  padding: 4px 1px 3px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.03);
  color: #dbe4dc;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--duration-fast) ease;
}

.sidebar-day-cell:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.sidebar-day-cell.empty {
  border-color: transparent;
  background: transparent;
  cursor: default;
  pointer-events: none;
}

.sidebar-day-cell.weekend {
  background: rgba(255, 255, 255, 0.015);
}

.sidebar-day-cell.has-records .day-num {
  color: #ffffff;
  font-weight: 700;
}

.sidebar-day-cell.selected {
  background: rgba(200, 75, 59, 0.25);
  border-color: var(--coral);
  box-shadow: 0 0 10px rgba(200, 75, 59, 0.35);
  transform: translateY(-1px);
}

.day-num {
  font-size: 11px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

/* Day Badges distinguishing Video and Opus */
.day-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 2px;
  width: 100%;
  height: 14px;
  min-height: 14px;
  margin-top: 1px;
  overflow: hidden;
}

.day-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 13px;
  height: 13px;
  padding: 0 2.5px;
  border-radius: var(--radius-full);
  font-size: 8.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  flex-shrink: 0;
}

.day-badge.badge-opus {
  background: var(--coral);
  color: #ffffff;
}

.day-badge.badge-video {
  background: var(--teal);
  color: #ffffff;
}

.day-badge.badge-favorite,
.day-badge.badge-fav {
  background: #fa8c16;
  color: #ffffff;
}

.day-badge.badge-other {
  background: var(--gold);
  color: #ffffff;
}

.badge-dot {
  font-size: 7px;
  line-height: 1;
}

/* Year & Month Quick Selector Popover */
.month-picker-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 310px;
  max-height: 380px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  box-shadow: var(--shadow-popover);
  z-index: 100;
  overflow-y: auto;
  animation: popoverFadeIn var(--duration-fast) var(--ease-spring);
  color: var(--ink);
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.picker-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.picker-label {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.picker-sub {
  color: var(--muted);
  font-size: 10px;
}

.picker-years-grid { display: grid; gap: 14px; }
.picker-year-block { display: grid; gap: 6px; }

.picker-year-title {
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.picker-months-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}

.picker-month-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.picker-month-btn:hover:not(:disabled) {
  border-color: var(--coral);
  color: var(--coral);
  background: var(--coral-soft);
}

.picker-month-btn.active {
  border-color: var(--coral);
  background: var(--coral);
  color: #ffffff;
  font-weight: 600;
}

.picker-month-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  background: transparent;
  border-color: transparent;
}

.picker-month-badge {
  font-size: 7.5px;
  line-height: 1;
  margin-top: 1px;
  opacity: 0.8;
}

/* ==========================================================================
   Filter Pills & Sidebar Details
   ========================================================================== */
.sidebar-block { margin-top: 18px; }

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.reset-filter-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: #8fa095;
  font-size: 10px;
  cursor: pointer;
  transition: color var(--duration-fast) ease;
}
.reset-filter-btn:hover { color: #f0b5a5; }

.filter-pills { display: grid; gap: 4px; }

.filter-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: #c4d1c8;
  font-size: 11.5px;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  text-align: left;
}

.filter-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.filter-pill.active {
  background: rgba(200, 75, 59, 0.22);
  border-color: rgba(200, 75, 59, 0.6);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(200, 75, 59, 0.2);
}

.filter-pill span { display: flex; align-items: center; }

.filter-pill strong {
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.type-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
}
.type-dot.all { background: #dbe4dc; }
.type-dot.opus { background: var(--coral); }
.type-dot.video { background: var(--teal); }
.type-dot.other { background: var(--gold); }

.filter-addon { margin-top: 6px; }

.toggle-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 9px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #aab8af;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.toggle-pill:hover { background: rgba(255, 255, 255, 0.05); color: #ffffff; }

.toggle-pill.active {
  border-style: solid;
  border-color: var(--teal);
  background: rgba(8, 126, 120, 0.18);
  color: #ffffff;
}

.checkbox-indicator {
  display: inline-grid;
  place-items: center;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.05);
}

.toggle-pill.active .checkbox-indicator {
  background: var(--teal);
  border-color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
}
.toggle-pill.active .checkbox-indicator::after {
  content: "";
  display: block;
  width: 3px;
  height: 6px;
  border: solid #ffffff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  margin-top: -1px;
}

.addon-count { font-variant-numeric: tabular-nums; opacity: 0.8; }

.date-range {
  margin: 6px 0 0;
  color: #dbe4dc;
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 14px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.data-status {
  color: #7d8f83;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.text-button {
  padding: 2px 6px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: #f0b5a5;
  cursor: pointer;
  font-size: 11px;
  transition: all var(--duration-fast) ease;
}
.text-button:hover { background: rgba(240, 181, 165, 0.1); color: #ffd6cb; }

/* ==========================================================================
   Main Workspace: Centered, Solid Width Hero Reading Stage
   ========================================================================== */
.workspace {
  min-width: 0;
  width: 100%;
  padding: 32px 48px 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.topbar,
.error-banner,
.search-results-panel,
.main-reader-stage {
  width: 100%;
  max-width: 980px;
  box-sizing: border-box;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  width: 100%;
}

.topbar-info {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.month-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-summary {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.filter-indicator-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--coral-soft);
  color: var(--coral);
  font-size: 10.5px;
  font-weight: 600;
}

.visible-count {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
  height: 38px;
  box-sizing: border-box;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) ease;
}

.search-box:focus-within {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-glow);
}

.search-icon { color: var(--coral); font-size: 18px; line-height: 1; }

.search-box input {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.clear-search {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e7ece8;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.clear-search:hover { background: var(--coral); color: #fff; }

.error-banner {
  margin-bottom: 18px;
  padding: 12px 16px;
  border-left: 4px solid var(--coral);
  border-radius: var(--radius-sm);
  background: var(--coral-soft);
  color: #8c352c;
  font-size: 13px;
}

/* Search Results Area (Unlimited & Reverse Chronological) */
.search-results-panel {
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  animation: searchPanelFadeIn var(--duration-fast) var(--ease-spring);
}

@keyframes searchPanelFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.search-head-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.search-results-head strong {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.search-count-badge {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.search-scope-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(20, 29, 25, 0.05);
  padding: 3px;
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .search-scope-tabs {
  background: rgba(255, 255, 255, 0.06);
}

.scope-btn {
  padding: 4px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.scope-btn:hover {
  color: var(--ink);
}

.scope-btn.active {
  background: var(--white);
  color: var(--teal);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.search-close-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--duration-fast) ease;
}

.search-close-btn:hover {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: var(--coral);
}

.search-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.search-tool-btn:hover {
  background: var(--teal-soft);
  color: var(--teal);
  border-color: var(--teal);
}

.search-tool-btn.highlight {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.search-collapsed-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.search-collapsed-bar:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.search-collapsed-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-collapsed-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 440px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.result-button {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  transition: all var(--duration-fast) ease;
}

.result-button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.result-button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: 0 0 0 1px var(--teal);
}

.result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.result-date {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  width: 78px;
}

.result-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  flex-shrink: 0;
}

.result-badge.opus { background: var(--coral-soft); color: var(--coral); }
.result-badge.video { background: var(--teal-soft); color: var(--teal); }

.result-chapter-badge {
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.result-title {
  flex: 1;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-arrow {
  color: var(--coral);
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.result-snippet {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  padding-left: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pagination Bar */
.search-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.search-pagination-info {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.search-pagination-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.search-page-numbers {
  display: flex;
  align-items: center;
  gap: 3px;
}

.search-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  color: var(--ink-soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.search-page-btn:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

.search-page-btn.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  font-weight: 600;
}

.search-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.search-page-ellipsis {
  color: var(--muted);
  font-size: 11px;
  padding: 0 2px;
}

.search-page-size-select {
  height: 26px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  color: var(--ink-soft);
  font-size: 11px;
  outline: none;
  cursor: pointer;
}

/* Dedicated Fullscreen Search Mode (独立成页双栏工作台) */
.search-results-panel.search-panel-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  margin: 0;
  padding: 16px 24px;
  z-index: 1080;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  border-radius: 0;
  border: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  animation: searchFullscreenFadeIn var(--duration-fast) var(--ease-spring);
}

@keyframes searchFullscreenFadeIn {
  from { opacity: 0; transform: scale(0.99); }
  to { opacity: 1; transform: scale(1); }
}

.search-fullscreen-body {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 0;
  margin-top: 10px;
}

.search-fullscreen-left {
  width: 440px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding-right: 16px;
  min-height: 0;
}

.search-fullscreen-left .results-list {
  flex: 1;
  max-height: none;
  overflow-y: auto;
  padding-right: 6px;
}

.search-fullscreen-right {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.search-fullscreen-preview-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-preview-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.search-preview-title {
  margin: 0;
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.search-preview-body {
  margin-top: 8px;
}

.search-fullscreen-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 280px;
  color: var(--muted);
  font-size: 13px;
}

.search-highlight {
  background: #fff3c4;
  color: #873800;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 600;
}

[data-theme="dark"] .search-highlight {
  background: #614700;
  color: #ffe58f;
}

[data-theme="dark"] .search-results-panel.search-panel-fullscreen {
  background: #141e19;
}

[data-theme="dark"] .search-fullscreen-right {
  background: #19241f;
  border-color: var(--line);
}

.no-results {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ==========================================================================
   Hero Reading Stage (Solid Width & Symmetrical Padding)
   ========================================================================== */
.main-reader-stage {
  min-width: 0;
  width: 100%;
}

.detail-panel {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-md);
  padding: 36px 40px 48px;
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Empty State */
.detail-empty {
  display: flex;
  min-height: 480px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
}

.empty-hero-graphic {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.empty-line {
  width: 44px;
  height: 3px;
  border-radius: 2px;
  background: var(--coral);
  margin-bottom: 12px;
}

.empty-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.detail-empty h3 {
  max-width: 480px;
  margin: 8px 0 12px;
  font-family: "Georgia", "Noto Serif SC", "Source Han Serif SC", serif;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.3;
}

.empty-desc {
  max-width: 520px;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.accent-opus { color: var(--coral); font-weight: 600; }
.accent-video { color: var(--teal); font-weight: 600; }

.empty-shortcuts-hint {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: rgba(20, 29, 25, 0.04);
  color: var(--muted);
  font-size: 11.5px;
}
.empty-shortcuts-hint code {
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(20, 29, 25, 0.08);
  font-family: monospace;
}

/* Active Article Reading */
.detail-article {
  width: 100%;
  max-width: var(--reading-max-width);
  margin: 0 auto;
  min-width: 0;
  transition: max-width 0.15s ease;
}

.detail-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.action-icon-btn.article-cite-btn:hover,
.action-icon-btn.article-chat-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

.action-icon-btn.article-cite-btn.referenced {
  border-color: rgba(8, 126, 120, 0.4);
  background: var(--teal-soft);
  color: var(--teal);
}

.action-icon-btn.article-cite-btn.referenced svg path {
  fill: currentColor;
}

.action-icon-btn.article-chat-btn.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.detail-date-badge-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-date {
  color: var(--coral);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.detail-type {
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 11px;
  font-weight: 600;
}

.detail-topline-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.action-icon-btn:hover {
  border-color: var(--coral);
  color: var(--coral);
  background: var(--coral-soft);
  transform: translateY(-1px);
}

/* Adjacent Record Navigation Bar */
.record-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  margin: 16px 0 14px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: rgba(20, 29, 25, 0.025);
  border: 1px solid var(--line);
}

.record-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--white);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.record-nav-btn:hover:not(:disabled) {
  border-color: var(--coral);
  color: var(--coral);
  background: var(--coral-soft);
}

.record-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: transparent;
  border-color: transparent;
}

.record-nav-index {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.detail-article h3 {
  margin: 20px 0 12px;
  font-family: var(--reading-font-family, inherit);
  font-size: clamp(22px, calc(var(--reading-font-size, 16px) * 1.55), 32px);
  font-weight: 700;
  line-height: 1.36;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  color: var(--ink);
  transition: font-family var(--duration-fast) ease;
}

.detail-meta {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* Day Multiple Records Switcher */
.day-records {
  display: grid;
  gap: 6px;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  margin: 0 0 22px;
  padding: 12px 4px 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.day-records-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.record-chip {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.record-chip:hover { background: #edf3ee; }

.record-chip::before {
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: var(--line-strong);
  content: "";
}

.record-chip.selected {
  background: #ffffff;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.record-chip.selected::before { background: var(--coral); }

.chip-title {
  overflow: hidden;
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-type-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.chip-type-tag.opus {
  background: var(--coral-soft);
  color: var(--coral);
}

.chip-type-tag.video {
  background: var(--teal-soft);
  color: var(--teal);
}

.chip-type-tag.other {
  background: var(--gold-soft);
  color: var(--gold);
}

.record-chip.selected .chip-type-tag.opus {
  background: var(--coral);
  color: #ffffff;
}

.record-chip.selected .chip-type-tag.video {
  background: var(--teal);
  color: #ffffff;
}

.record-chip.selected .chip-type-tag.other {
  background: var(--gold);
  color: #ffffff;
}

/* Detail Body Typography */
.relation-rail {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  margin: 4px 0 18px;
  padding: 9px 0 9px 13px;
  border-left: 2px solid var(--evidence);
  background: linear-gradient(90deg, var(--evidence-soft), transparent 78%);
}

.relation-rail[hidden], .relation-panel[hidden] { display: none; }

.relation-rail-label {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.relation-thread-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--evidence);
}

.relation-entities {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.relation-entity-chip,
.entity-mark {
  border: 0;
  color: var(--evidence);
  cursor: pointer;
  font: inherit;
}

.relation-entity-chip {
  padding: 3px 8px;
  border: 1px solid rgba(201, 75, 86, 0.24);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--paper) 76%, var(--evidence-soft));
  font-size: 11.5px;
  line-height: 1.35;
  transition: all var(--duration-fast) ease;
}

.relation-entity-chip:hover,
.relation-entity-chip[aria-pressed="true"] {
  border-color: var(--evidence);
  background: var(--evidence-soft);
}

.relation-entity-chip.stock-chip {
  border-color: rgba(201, 75, 86, 0.45);
  background: var(--evidence-soft);
  color: var(--evidence);
  font-weight: 600;
}
.relation-entity-chip.stock-chip:hover {
  background: var(--evidence);
  color: #ffffff;
}

.article-market-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--evidence-soft);
  border: 1px solid rgba(201, 75, 86, 0.4);
  border-radius: var(--radius-xs);
  color: var(--evidence);
  font-weight: 650;
  font-size: 11.5px;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.article-market-btn:hover {
  background: var(--evidence);
  color: #ffffff;
  border-color: var(--evidence);
}
.article-market-btn[hidden] {
  display: none;
}

.entity-mark {
  display: inline;
  margin: 0;
  padding: 0 1px;
  background: transparent;
  font-weight: 650;
  line-height: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(201, 75, 86, 0.55);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.entity-mark:hover,
.entity-mark[aria-pressed="true"] {
  background: var(--evidence-soft);
  text-decoration-color: var(--evidence);
}

.relation-panel {
  width: 100%;
  margin: -6px 0 20px;
  padding: 16px 17px 17px;
  border: 1px solid rgba(201, 75, 86, 0.28);
  border-top: 2px solid var(--evidence);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--paper);
  box-shadow: var(--shadow-md);
}

.relation-panel-header,
.relation-panel-section-head,
.relation-source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.relation-panel-kicker {
  color: var(--evidence);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.relation-panel-header h4 {
  margin: 2px 0 0;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 18px;
}

.relation-panel-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.relation-panel-content { margin-top: 14px; }
.relation-panel-loading, .relation-panel-empty { color: var(--muted); font-size: 12.5px; }
.relation-warning { margin: 0 0 12px; color: var(--gold); font-size: 12px; }
.relation-panel-section + .relation-panel-section { margin-top: 16px; }
.relation-panel-section-head { margin-bottom: 7px; }
.relation-panel-section-head strong { color: var(--ink); font-size: 12.5px; }
.relation-panel-section-head span { color: var(--muted); font-size: 10.5px; }

.relation-path-list, .relation-source-list { display: grid; gap: 7px; }
.relation-path-card {
  padding: 9px 10px;
  border-left: 2px solid rgba(201, 75, 86, 0.48);
  background: var(--paper-soft);
}
.relation-path-line { color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.relation-path-line b { color: var(--evidence); font-weight: 650; }
.relation-evidence { margin-top: 4px; color: var(--muted); font-size: 10.5px; line-height: 1.45; }

.relation-source-row {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  text-align: left;
}
.relation-source-row:hover { border-color: rgba(201, 75, 86, 0.38); background: var(--evidence-soft); }
.relation-source-main { min-width: 0; }
.relation-source-title { display: block; overflow: hidden; font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.relation-source-meta { display: block; color: var(--muted); font-size: 10px; }
.relation-source-kind { flex: 0 0 auto; color: var(--evidence); font-family: var(--font-mono); font-size: 9.5px; }
.relation-kline-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.relation-mini-kline-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  padding: 10px 12px;
  overflow: hidden;
}
.relation-mini-kline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.relation-mini-kline-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.relation-mini-kline-title strong {
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 700;
}
.relation-mini-kline-title span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.relation-mini-quote {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
}
.relation-mini-price {
  font-size: 15px;
  font-weight: 700;
}
.relation-mini-pct {
  font-size: 11.5px;
  font-weight: 600;
}
.relation-mini-price.up, .relation-mini-pct.up { color: var(--red); }
.relation-mini-price.down, .relation-mini-pct.down { color: var(--green); }
.relation-mini-price.flat, .relation-mini-pct.flat { color: var(--muted); }

.relation-mini-anchor-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  margin-bottom: 8px;
  border-left: 2px solid var(--evidence);
  background: var(--evidence-soft);
  border-radius: 0 4px 4px 0;
  font-size: 11px;
  color: var(--ink-soft);
}
.relation-mini-anchor-info b {
  font-family: var(--font-mono);
  color: var(--evidence);
}

.relation-mini-period-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  align-items: center;
}
.relation-period-btn {
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.relation-period-btn:hover {
  background: var(--paper-warm);
  color: var(--ink);
}
.relation-period-btn.active {
  background: var(--paper-warm);
  color: var(--gold);
  border-color: var(--gold);
  font-weight: 700;
}

.relation-mini-chart-wrap {
  width: 100%;
  height: 200px;
  position: relative;
}
.relation-mini-chart {
  width: 100%;
  height: 100%;
}

.relation-mini-links {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.relation-kline-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
  background: transparent;
}
.relation-kline-link:hover {
  color: var(--evidence);
  border-color: rgba(201, 75, 86, 0.4);
  background: var(--evidence-soft);
}

/* AI 点评卡片 */
.relation-kline-ai-critique {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(201, 75, 86, 0.28);
  border-radius: var(--radius-sm);
  background: var(--paper-warm);
}
.relation-ai-critique-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.relation-ai-critique-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--evidence);
}
.relation-ai-critique-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.relation-ai-critique-btn {
  padding: 2px 6px;
  font-size: 10.5px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.relation-ai-critique-btn:hover {
  color: var(--ink);
  border-color: var(--muted);
}
.relation-ai-critique-body {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.relation-ai-critique-body p {
  margin: 0 0 6px;
}
.relation-ai-critique-body p:last-child {
  margin-bottom: 0;
}
.relation-ai-critique-body ul, .relation-ai-critique-body ol {
  margin: 4px 0 6px;
  padding-left: 18px;
}
.relation-ai-critique-body li {
  margin-bottom: 3px;
}
.relation-ai-critique-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
}
.relation-ai-critique-empty {
  color: var(--muted);
  font-size: 11px;
}

.detail-body {
  width: 100%;
  max-width: var(--reading-max-width);
  color: var(--ink-soft);
  font-size: var(--reading-font-size);
  line-height: var(--reading-line-height);
  font-family: var(--reading-font-family);
  transition: font-size 0.15s ease, line-height 0.15s ease, max-width 0.15s ease;
}

.detail-body p,
.detail-body blockquote,
.detail-body ul,
.detail-body ol,
.detail-body li {
  line-height: var(--reading-line-height);
  overflow-wrap: break-word;
}
.detail-body p { margin: 0 0 var(--reading-paragraph-gap); }

.detail-body h4 {
  margin: 24px 0 12px;
  color: var(--ink);
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

.detail-body ul { margin: 0 0 18px; padding-left: 22px; }
.detail-body li { margin-bottom: 6px; }

.detail-body a {
  color: var(--teal);
  text-decoration: underline;
  text-decoration-color: rgba(8, 126, 120, 0.4);
  text-underline-offset: 3px;
  transition: color var(--duration-fast) ease;
}
.detail-body a:hover { color: var(--teal-hover); text-decoration-color: var(--teal); }

.detail-body code {
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: #e8eee8;
  color: #2b3a32;
  font-family: Consolas, "Cascadia Code", Monaco, monospace;
  font-size: 12.5px;
}

.muted-copy { color: var(--muted); font-style: italic; }

@media (max-width: 720px) {
  .relation-rail { align-items: flex-start; gap: 8px; overflow: hidden; }
  .relation-rail-label { padding-top: 4px; }
  .relation-entities { flex-wrap: nowrap; overflow-x: auto; padding-right: 8px; scrollbar-width: none; }
  .relation-entities::-webkit-scrollbar { display: none; }
  .relation-entity-chip { flex: 0 0 auto; }
  .relation-panel {
    position: fixed;
    z-index: 1200;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(72vh, 620px);
    margin: 0;
    overflow-y: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -18px 48px rgba(10, 18, 14, 0.2);
  }
}

/* Image Gallery */
.detail-images {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  width: 100%;
}

.gallery-grid {
  display: grid;
  gap: 12px;
  width: 100%;
}

.gallery-grid.grid-1 { grid-template-columns: 1fr; }
.gallery-grid.grid-2 { grid-template-columns: repeat(2, 1fr); }
.gallery-grid.grid-3 { grid-template-columns: repeat(3, 1fr); }
.gallery-grid.grid-multi { grid-template-columns: repeat(3, 1fr); }

.gallery-card {
  position: relative;
  margin: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #eef3ee;
  cursor: zoom-in;
  transition: transform var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--coral);
}

.gallery-card img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 520px;
  object-fit: cover;
}

.gallery-grid.grid-1 .gallery-card img {
  max-height: 600px;
  object-fit: contain;
  background: #f4f7f4;
}

.gallery-grid.grid-2 .gallery-card,
.gallery-grid.grid-3 .gallery-card,
.gallery-grid.grid-multi .gallery-card {
  aspect-ratio: 1 / 1;
}

.gallery-overlay-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(10, 16, 13, 0.76);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}

/* Detail Actions */
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  width: 100%;
}

.action-link.outline-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) ease;
}

.action-link.outline-btn:hover {
  border-color: var(--coral);
  color: var(--coral);
  background: var(--coral-soft);
  transform: translateY(-1px);
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  transition: all var(--duration-fast) ease;
}

.action-link.highlight {
  background: var(--coral-soft);
  color: var(--coral);
}
.action-link.highlight:hover {
  background: var(--coral);
  color: #ffffff;
}

.action-link.muted {
  border: 1px solid var(--line-strong);
  color: var(--muted);
}
.action-link.muted:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.action-link.quiet-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.action-link.quiet-btn:hover { color: var(--coral); }

/* ==========================================================================
   Full Screen Image Lightbox Modal
   ========================================================================== */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lightboxFadeIn var(--duration-fast) ease;
}

@keyframes lightboxFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 15, 0.94);
  backdrop-filter: blur(16px);
}

.lightbox-container {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  color: #fff;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
}

.lightbox-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.lightbox-counter {
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.lightbox-title {
  color: #dbe4dc;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.05);
}

.lightbox-btn.close-btn:hover {
  background: var(--coral);
  border-color: var(--coral);
}

.lightbox-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 80px;
  overflow: hidden;
}

.lightbox-img-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  user-select: none;
  cursor: zoom-in;
}

.lightbox-img-wrapper.zoomed {
  overflow: auto;
  cursor: zoom-out;
  display: block;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-xs);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transition: transform var(--duration-fast) var(--ease-spring);
}

.lightbox-img-wrapper.zoomed .lightbox-img {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: rgba(18, 26, 22, 0.7);
  backdrop-filter: blur(8px);
  color: #fff;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  z-index: 2;
}

.lightbox-nav-btn.prev { left: 24px; }
.lightbox-nav-btn.next { right: 24px; }

.lightbox-nav-btn:hover:not(:disabled) {
  background: var(--coral);
  border-color: var(--coral);
  transform: translateY(-50%) scale(1.08);
}

.lightbox-nav-btn:disabled { opacity: 0.2; cursor: not-allowed; }

.lightbox-thumbnails {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  background: linear-gradient(0deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
  overflow-x: auto;
}

.lightbox-thumb {
  width: 50px;
  height: 50px;
  border: 2px solid transparent;
  border-radius: var(--radius-xs);
  overflow: hidden;
  opacity: 0.5;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  flex: 0 0 auto;
}

.lightbox-thumb.active {
  border-color: var(--coral);
  opacity: 1;
  transform: scale(1.08);
}

.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 22px;
  border-radius: var(--radius-full);
  background: #141c19;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-spring);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

[hidden] { display: none !important; }

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 320px minmax(0, 1fr); }
  .workspace { padding: 24px 28px 40px; }
  .detail-panel { padding: 32px 32px 40px; }
}

@media (max-width: 860px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
    box-sizing: border-box;
    font-size: clamp(13px, 3.6vw, 15px);
  }
  .app-shell {
    display: block;
    max-width: 100vw;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }
  .sidebar {
    position: relative;
    height: auto;
    padding: clamp(12px, 3vw, 18px) clamp(10px, 2.5vw, 14px);
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .workspace {
    padding: clamp(12px, 3vw, 16px) clamp(8px, 2vw, 12px) 32px;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .topbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: clamp(4px, 1.2vw, 8px);
    max-width: 100%;
    box-sizing: border-box;
  }
  .topbar-actions {
    width: 100%;
    display: flex;
    align-items: center;
    gap: clamp(3px, 1vw, 6px);
    flex-wrap: nowrap;
    min-width: 0;
  }
  .search-box {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    font-size: clamp(11px, 2.8vw, 13px);
  }
  .search-input {
    font-size: clamp(11px, 2.8vw, 13px);
    padding-left: clamp(24px, 6vw, 30px);
  }
  .action-icon-btn {
    width: clamp(28px, 7.5vw, 34px);
    height: clamp(28px, 7.5vw, 34px);
    flex-shrink: 0;
  }
  .detail-panel {
    padding: clamp(14px, 3.5vw, 20px) clamp(10px, 2.5vw, 14px);
    min-height: auto;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .month-picker-popover {
    max-width: calc(100vw - 20px);
    width: 100%;
    left: 0;
    box-sizing: border-box;
  }
  .detail-article h3,
  .detail-header h2 {
    font-size: clamp(16px, 4.2vw, 21px);
    line-height: 1.35;
    word-break: break-word;
  }
  .detail-body {
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    font-size: clamp(13.5px, 3.6vw, 16px);
  }
  .gallery-grid.grid-3, .gallery-grid.grid-multi {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .reading-prefs-tabs {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 3px !important;
    padding: 6px 8px 0 !important;
  }
  .reading-tab-btn {
    padding: 5px 2px !important;
  }
  .reading-tab-name {
    font-size: 10px !important;
  }
  .reading-tab-val {
    font-size: 8.5px !important;
  }
  .prefs-quick-presets {
    gap: 4px !important;
    flex-wrap: nowrap !important;
  }
  .preset-pill {
    font-size: 10.5px !important;
    padding: 5px 3px !important;
    white-space: nowrap !important;
  }
  .admin-table {
    font-size: 10.5px !important;
  }
  .admin-table th,
  .admin-table td {
    padding: 6px 4px !important;
  }
  .admin-micro-btn {
    padding: 2px 5px !important;
    font-size: 9.5px !important;
  }
  .role-pill {
    padding: 1px 4px !important;
    font-size: 9.5px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
/* Action Primary Button (e.g. + 新建记录) */
.action-button-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--coral);
  border-radius: var(--radius-sm);
  background: var(--coral);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
}

.action-button-primary:hover {
  background: var(--coral-hover);
  border-color: var(--coral-hover);
  box-shadow: 0 2px 8px rgba(200, 75, 59, 0.35);
  transform: translateY(-1px);
}

.action-button-primary .btn-icon {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

/* ==========================================================================
   Editor Modal Styling (Warm Paper & Deep Ink Theme)
   ========================================================================== */
.editor-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: editorFadeIn var(--duration-fast) ease;
}

@keyframes editorFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 20, 17, 0.75);
  backdrop-filter: blur(8px);
}

.editor-container {
  position: relative;
  width: 100%;
  max-width: 740px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  z-index: 1;
  overflow: hidden;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 26px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-card);
}

.editor-header h3 {
  margin: 0;
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.editor-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.editor-close-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.editor-close-btn:hover {
  background: rgba(20, 29, 25, 0.08);
  color: var(--ink);
}

.editor-form {
  padding: 22px 26px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.flex-1 { flex: 1; }
.form-group.flex-2 { flex: 2; }

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.form-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.form-hint {
  font-size: 11px;
  color: var(--muted);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink);
  font-size: 13px;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-glow);
  outline: none;
}

.form-textarea {
  resize: vertical;
  min-height: 160px;
  font-family: inherit;
  line-height: 1.6;
}

.form-error {
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  background: var(--coral-soft);
  color: var(--coral);
  font-size: 12px;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.editor-status-text {
  font-size: 11.5px;
  color: var(--muted);
}

.editor-btn-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.editor-btn.secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface-card);
  color: var(--ink-soft);
}

.editor-btn.secondary:hover {
  background: var(--paper-soft);
  border-color: var(--ink);
}

.editor-btn.primary {
  border: 1px solid var(--coral);
  background: var(--coral);
  color: #ffffff;
  box-shadow: var(--shadow-xs);
}

.editor-btn.primary:hover {
  background: var(--coral-hover);
  border-color: var(--coral-hover);
  box-shadow: 0 2px 8px rgba(200, 75, 59, 0.3);
}
/* ==========================================================================
   Dark Theme (深色模式) Support
   ========================================================================== */
[data-theme="dark"] {
  --ink: #edf5ee;
  --ink-soft: #c8d8cd;
  --ink-light: #94aa9d;
  --muted: #799183;
  --muted-light: #566c60;
  
  --paper: #16201b;
  --paper-soft: #1c2923;
  --canvas: #0d1411;
  --surface-card: #1a2520;
  
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --line-focus: rgba(235, 95, 78, 0.45);
  
  --coral: #eb5f4e;
  --coral-hover: #f37768;
  --coral-soft: rgba(235, 95, 78, 0.16);
  --coral-glow: rgba(235, 95, 78, 0.28);
  
  --teal: #1cb5ab;
  --teal-hover: #33d1c7;
  --teal-soft: rgba(28, 181, 171, 0.16);
  
  --gold: #dfa837;
  --gold-soft: rgba(223, 168, 55, 0.16);
  --web: #83aef2;
  
  --white: #1c2722;
  
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 18px 40px -6px rgba(0, 0, 0, 0.75);
  --shadow-popover: 0 22px 48px -8px rgba(0, 0, 0, 0.85);

  color-scheme: dark;
}

[data-theme="dark"] .sidebar {
  background: #0f1613;
  border-right-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .record-chip:hover {
  background: #23312a;
}

[data-theme="dark"] .record-chip.selected {
  background: #1c2722;
  border-color: var(--line-strong);
}

[data-theme="dark"] .action-icon-btn,
[data-theme="dark"] .action-link.outline-btn,
[data-theme="dark"] .record-nav-btn {
  background: #1c2722;
  color: var(--ink-soft);
  border-color: var(--line-strong);
}

[data-theme="dark"] .search-box {
  background: #16201b;
  border-color: var(--line-strong);
}

[data-theme="dark"] .search-box input {
  color: #edf5ee;
}

[data-theme="dark"] .search-results-panel {
  background: #16201b;
  border-color: var(--line-strong);
}

[data-theme="dark"] .result-button {
  background: #1a2520;
  border-color: var(--line);
  color: var(--ink-soft);
}

[data-theme="dark"] .result-button:hover,
[data-theme="dark"] .result-button.active {
  background: rgba(8, 126, 120, 0.16);
  border-color: var(--teal);
}

[data-theme="dark"] .result-badge {
  background: #24332c;
  color: var(--muted);
}

[data-theme="dark"] .search-highlight {
  background: #634b07;
  color: #ffe58f;
}

[data-theme="dark"] .history-card {
  background: #1a2520;
  border-color: var(--line);
}

[data-theme="dark"] .history-card:hover {
  background: #202e28;
  border-color: var(--teal);
}

[data-theme="dark"] .history-card.active {
  background: rgba(8, 126, 120, 0.18);
  border-color: var(--teal);
}

[data-theme="dark"] .history-empty-item {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
}

[data-theme="dark"] .font-card {
  background: #18231e;
  border-color: var(--line);
}

[data-theme="dark"] .font-card:hover {
  background: #1f2c25;
  border-color: var(--teal);
}

[data-theme="dark"] .font-card.active {
  background: rgba(8, 126, 120, 0.18);
  border-color: var(--teal);
}

[data-theme="dark"] .font-card-tag {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

[data-theme="dark"] .prefs-live-preview-box {
  background: #141d18;
  border-color: var(--line-strong);
}

[data-theme="dark"] .gallery-card {
  background: #18231e;
  border-color: var(--line-strong);
}

[data-theme="dark"] .gallery-grid.grid-1 .gallery-card img {
  background: #18231e;
}

[data-theme="dark"] .detail-body code {
  background: #223029;
  color: #a8d5be;
}

[data-theme="dark"] .empty-shortcuts-hint {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

[data-theme="dark"] .empty-shortcuts-hint code {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .editor-header {
  background: #16201b;
}

[data-theme="dark"] .editor-container {
  background: #141c18;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
  background: #1a2520;
  color: #edf5ee;
  border-color: var(--line-strong);
}

[data-theme="dark"] .editor-btn.secondary {
  background: #1c2722;
  color: var(--ink-soft);
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--white);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) ease;
}

.theme-toggle:hover {
  border-color: var(--coral);
  color: var(--coral);
  background: var(--coral-soft);
  transform: translateY(-1px);
}

/* Truncation Banner & Warning Pill */
.type-dot.warning {
  background: #faad14;
  box-shadow: 0 0 6px rgba(250, 173, 20, 0.45);
}

.filter-pill.warning-pill {
  border-color: rgba(250, 173, 20, 0.25);
}

.filter-pill.warning-pill.active {
  background: rgba(250, 173, 20, 0.15);
  border-color: #faad14;
}

.truncation-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border: 1px solid #ffe58f;
  border-radius: var(--radius-sm);
  background: #fffbe6;
  color: #873800;
  box-shadow: var(--shadow-xs);
  animation: searchPanelFadeIn var(--duration-fast) var(--ease-spring);
}

[data-theme="dark"] .truncation-banner {
  background: rgba(250, 173, 20, 0.12);
  border-color: rgba(250, 173, 20, 0.3);
  color: #ffd666;
}

.banner-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  line-height: 1.45;
}

.banner-text strong {
  font-weight: 600;
  font-size: 13px;
}

.banner-text span {
  opacity: 0.85;
}

#quickEditTruncatedBtn {
  flex-shrink: 0;
  white-space: nowrap;
}
.editor-btn.outline-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.form-checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}

.form-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--coral);
  cursor: pointer;
}

/* Truncation Review Queue Bar */
.truncation-queue-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 16px;
  background: rgba(250, 173, 20, 0.08);
  border: 1px solid rgba(250, 173, 20, 0.3);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  animation: searchPanelFadeIn var(--duration-fast) var(--ease-spring);
}

[data-theme="dark"] .truncation-queue-bar {
  background: rgba(250, 173, 20, 0.12);
  border-color: rgba(250, 173, 20, 0.35);
}

.queue-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.queue-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #faad14;
  color: #ffffff;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

[data-theme="dark"] .queue-badge {
  background: #d48806;
  color: #ffffff;
}

.queue-count-text {
  font-size: 12px;
  color: var(--ink-soft);
}

.queue-count-text strong {
  color: #d48806;
  font-size: 13.5px;
  font-weight: 700;
}

[data-theme="dark"] .queue-count-text strong {
  color: #ffd666;
}

.queue-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.queue-btn {
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) ease;
}

.queue-btn:hover {
  border-color: #faad14;
  color: #d48806;
  background: var(--paper-soft);
  transform: translateY(-1px);
}

.queue-btn.highlight {
  border-color: #faad14;
  background: #faad14;
  color: #ffffff;
}

.queue-btn.highlight:hover {
  background: #d48806;
  border-color: #d48806;
}

.queue-btn.list-btn {
  background: transparent;
  border-color: rgba(250, 173, 20, 0.4);
  color: var(--ink-soft);
}

/* Queue Drawer Dropdown */
.queue-drawer {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 100;
  padding: 14px 16px;
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  max-height: 380px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: searchPanelFadeIn var(--duration-fast) ease;
}

.queue-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.queue-drawer-header strong {
  font-size: 13px;
  color: var(--ink);
}

.queue-drawer-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.queue-drawer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.queue-drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--paper);
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  transition: all var(--duration-fast) ease;
}

.queue-drawer-item:hover {
  border-color: #faad14;
  background: rgba(250, 173, 20, 0.08);
}

.queue-drawer-item.active {
  border-color: #faad14;
  background: rgba(250, 173, 20, 0.15);
  font-weight: 600;
}

.queue-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.queue-item-date {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  width: 76px;
}

.queue-item-title {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item-arrow {
  color: #faad14;
  font-size: 14px;
  flex-shrink: 0;
}

/* Editor Image Paste & Thumbnail Strip */
.editor-images-section {
  padding: 10px 14px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.editor-images-list {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 2px;
}

.editor-image-card {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--canvas);
}

.editor-image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.editor-image-delete {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.editor-image-delete:hover {
  opacity: 1;
  background: var(--coral);
  transform: scale(1.1);
}

/* Inline Markdown Image Rendering in Reader */
.body-inline-image {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.body-inline-image img {
  max-width: 100%;
  max-height: 520px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--duration-fast) ease;
}

.body-inline-image img:hover {
  transform: scale(1.01);
}

.body-inline-image figcaption {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}
.editor-footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-btn.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  transition: all 0.15s ease;
}

.editor-btn.danger:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.editor-btn.warning {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border: 1px solid rgba(2, 132, 199, 0.3);
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  transition: all 0.15s ease;
}

.editor-btn.warning:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

/* ==========================================================================
   User Role Isolation & Switcher
   ========================================================================== */
body[data-role="reader"] .admin-only {
  display: none !important;
}

.role-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  width: auto;
  border-radius: var(--radius-full);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.role-toggle:hover {
  background: var(--surface-card);
  border-color: var(--teal);
  color: var(--teal);
  box-shadow: var(--shadow-xs);
}

.role-label {
  letter-spacing: 0.2px;
}

/* ==========================================================================
   Reading Preferences Modal (4-Category Reading Settings)
   ========================================================================== */
.prefs-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.prefs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 14, 0.55);
  backdrop-filter: blur(6px);
}

.prefs-container {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  max-height: 90dvh;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.22s var(--ease-spring);
  box-sizing: border-box;
}

.prefs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
  flex-shrink: 0;
}

.prefs-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.prefs-header-icon {
  color: var(--teal);
  flex-shrink: 0;
}

.prefs-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.prefs-subtitle {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.prefs-close-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--duration-fast) ease;
}

.prefs-close-btn:hover {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: var(--coral);
}

/* 4-Category Reading Preference Tab Navigation */
.reading-prefs-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 16px 0;
  background: var(--paper-soft);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.reading-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.16s ease;
  position: relative;
}

.reading-tab-btn:hover {
  color: var(--teal);
  background: rgba(8, 126, 120, 0.06);
}

.reading-tab-btn.active {
  background: var(--paper);
  color: var(--teal);
  border-color: var(--line) var(--line) var(--paper);
  font-weight: 600;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.03);
}

.reading-tab-icon {
  font-size: 15px;
  line-height: 1;
}

.reading-tab-name {
  font-size: 11px;
  font-weight: 600;
}

.reading-tab-val {
  font-size: 10px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.04);
  padding: 1px 5px;
  border-radius: var(--radius-full);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reading-tab-btn.active .reading-tab-val {
  color: var(--teal);
  background: var(--teal-soft);
  font-weight: 600;
}

.prefs-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}

.prefs-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeIn 0.18s ease;
}

.prefs-panel[hidden] {
  display: none !important;
}

.prefs-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prefs-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prefs-label-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.prefs-val-badge {
  font-size: 11.5px;
  color: var(--teal);
  background: var(--teal-soft);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.prefs-quick-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-pill {
  flex: 1 1 auto;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-card);
  color: var(--ink-soft);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.preset-pill:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--paper-soft);
}

.preset-pill.active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(8, 126, 120, 0.25);
}

.prefs-options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pref-opt-btn {
  flex: 1 1 auto;
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--ink-soft);
  cursor: pointer;
  text-align: center;
  transition: all var(--duration-fast) ease;
}

.pref-opt-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--paper-soft);
}

.pref-opt-btn.active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(8, 126, 120, 0.28);
}

/* Universal Typography Selection Grid */
.prefs-font-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (max-width: 580px) {
  .prefs-font-cards-grid {
    grid-template-columns: 1fr;
  }
}

.font-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface-card);
  cursor: pointer;
  transition: all var(--duration-fast) cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  text-align: left;
}

.font-card:hover {
  border-color: var(--teal);
  background: var(--paper-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.font-card.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: 0 0 0 2px rgba(8, 126, 120, 0.25);
}

.font-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.2px;
}

.font-card.active .font-card-name {
  color: var(--teal);
}

.font-card-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.1px;
}

.font-card.active .font-card-tag {
  color: var(--teal);
  font-weight: 600;
}

/* Live Typography Preview Box */
.prefs-preview-group {
  margin-top: 4px;
}

.prefs-val-badge.preview-badge {
  background: rgba(8, 126, 120, 0.12);
  color: var(--teal);
  font-weight: 600;
}

.prefs-live-preview-box {
  background: var(--paper-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all var(--duration-fast) ease;
  font-family: var(--reading-font-family);
}

.preview-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  font-size: 11px;
}

.preview-box-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-tag-type {
  font-weight: 600;
  color: var(--teal);
  display: flex;
  align-items: center;
  gap: 4px;
}

.preview-tag-type .type-dot {
  width: 6px;
  height: 6px;
  background: var(--teal);
  border-radius: 50%;
  display: inline-block;
}

.preview-meta-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.preview-tag-indicator {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--teal);
  background: var(--teal-soft);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.preview-box-title {
  margin: 0 0 10px;
  font-size: calc(var(--reading-font-size) * 1.1);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
  font-family: inherit;
}

.preview-box-content {
  font-size: var(--reading-font-size);
  line-height: var(--reading-line-height);
  color: var(--ink-soft);
  font-family: inherit;
}

.preview-box-content p {
  margin: 0 0 8px;
}

.preview-box-content strong {
  color: var(--ink);
  font-weight: 600;
}

.prefs-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--paper-soft);
  flex-shrink: 0;
}

.prefs-btn {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: all var(--duration-fast) ease;
}

.prefs-btn.secondary {
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--muted);
}

.prefs-btn.secondary:hover {
  border-color: var(--ink-light);
  color: var(--ink);
}

.prefs-btn.primary {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.prefs-btn.primary:hover {
  background: var(--teal-hover);
  border-color: var(--teal-hover);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Admin Console Modal (Dedicated Admin Workspace)
   ========================================================================== */
.admin-console-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.admin-console-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 14, 0.6);
  backdrop-filter: blur(6px);
}

.admin-console-container {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  max-height: 90dvh;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.22s var(--ease-spring);
  box-sizing: border-box;
}

.admin-console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
  flex-shrink: 0;
}

.admin-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-header-icon {
  color: var(--gold);
  flex-shrink: 0;
}

.admin-console-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.admin-subtitle {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.admin-close-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--duration-fast) ease;
}

.admin-close-btn:hover {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: var(--coral);
}

.admin-console-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

.admin-card {
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-xs);
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.admin-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.admin-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--teal-soft);
  color: var(--teal);
}

.admin-card-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* Modern Admin Table */
.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.admin-table th {
  background: var(--paper-soft);
  padding: 10px 12px;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.role-pill.admin {
  background: #0f766e;
  color: #ffffff;
  border: 1px solid #0d9488;
}

.role-pill.reader {
  background: #475569;
  color: #ffffff;
  border: 1px solid #334155;
}

.active-now-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #059669;
  font-weight: 600;
  font-size: 11px;
}

.admin-micro-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-card);
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.admin-micro-btn:hover {
  border-color: #0f766e;
  color: #ffffff;
  background: #0f766e;
}

.admin-micro-btn.danger {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.35);
  background: transparent;
  margin-left: 4px;
}

.admin-micro-btn.danger:hover {
  border-color: #dc2626;
  background: #dc2626;
  color: #ffffff;
}

.admin-create-user-card {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.admin-create-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.admin-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-input-group label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.admin-input-group input,
.admin-input-group select {
  padding: 7px 10px;
  font-size: 12.5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink);
  box-sizing: border-box;
  width: 100%;
}

.admin-create-actions,
.admin-llm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.admin-btn.primary {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.admin-btn.primary:hover {
  background: var(--teal-hover);
  box-shadow: var(--shadow-sm);
}

.admin-btn.secondary {
  background: var(--paper-soft);
  border-color: var(--line-strong);
  color: var(--ink);
}

.admin-btn.secondary:hover {
  background: var(--surface-card);
  border-color: var(--teal);
  color: var(--teal);
}

.admin-btn.outline {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.admin-btn.outline:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.admin-sync-result {
  margin-top: 8px;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  color: var(--ink);
}

.archive-progress {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
}

.archive-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.archive-progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.archive-progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 320ms ease;
}

.archive-progress-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.archive-progress-steps span.done { color: var(--teal); font-weight: 700; }
.archive-progress-steps span.active { color: var(--ink); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .archive-progress-track > span { transition: none; }
}

.admin-console-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: var(--paper-soft);
  flex-shrink: 0;
}

/* ==========================================================================
   Topbar Control Alignment (Pixel-Perfect Horizontal & Vertical Balance)
   ========================================================================== */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-actions .search-box {
  height: 34px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  padding: 0 8px 0 10px;
}

.topbar-actions .action-icon-btn {
  height: 34px;
  width: 34px;
  padding: 0;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--white);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  cursor: pointer;
  transform: none !important;
  transition: border-color var(--duration-fast) ease, color var(--duration-fast) ease, background var(--duration-fast) ease;
}

.topbar-actions .action-icon-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
  box-shadow: var(--shadow-xs);
  transform: none !important;
}

.topbar-actions .role-toggle {
  height: 34px;
  width: auto;
  padding: 0 12px;
  gap: 6px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transform: none !important;
  transition: all var(--duration-fast) ease;
}

.topbar-actions .role-toggle:hover {
  background: var(--surface-card);
  border-color: var(--teal);
  color: var(--teal);
  box-shadow: var(--shadow-xs);
  transform: none !important;
}

.role-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
}

.topbar-actions .prefs-btn svg,
.topbar-actions .theme-toggle svg {
  display: block;
}

/* ==========================================================================
   Rich Markdown Typography (Bold, Headings, Quotes, Lists)
   ========================================================================== */
.detail-body strong,
.detail-body b {
  font-weight: 700;
  color: var(--ink);
}

.detail-body em,
.detail-body i {
  font-style: italic;
}

.detail-body h2,
.detail-body h3,
.detail-body h4,
.detail-body h5,
.detail-body h6 {
  margin: 22px 0 10px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.detail-body h2 {
  font-size: 1.22em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.detail-body h3 {
  font-size: 1.12em;
}

.detail-body h4 {
  font-size: 1.04em;
}

.detail-body blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  border-left: 3px solid var(--teal);
  background: var(--paper-soft);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: var(--ink-soft);
  font-size: 0.95em;
  line-height: 1.6;
}

.detail-body ul,
.detail-body ol {
  margin: 12px 0;
  padding-left: 24px;
}

.detail-body li {
  margin-bottom: 6px;
  line-height: 1.65;
}

.detail-body code {
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--teal);
}

/* ==========================================================================
   User Auth, User Management & Sidebar History Styles
   ========================================================================== */

/* User Auth Button in Topbar */
.user-auth-btn {
  height: 34px;
  width: auto;
  padding: 0 12px;
  gap: 6px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transform: none !important;
  transition: all var(--duration-fast) ease;
}

.user-auth-btn:hover {
  background: var(--surface-card);
  border-color: var(--teal);
  color: var(--teal);
  box-shadow: var(--shadow-xs);
}

body[data-role="admin"] .user-auth-btn {
  border-color: rgba(224, 90, 71, 0.35);
  background: var(--coral-soft);
  color: var(--coral);
}

/* Sidebar History Section */
.history-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-label-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-label-group .section-icon {
  color: var(--teal);
  opacity: 0.85;
}

.history-count-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  background: var(--teal-soft);
  color: var(--teal);
  border-radius: var(--radius-full);
}

.history-clear-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) ease;
}

.history-clear-btn:hover {
  color: var(--coral);
  background: var(--coral-soft);
  border-color: var(--coral);
}

.recent-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  width: 100%;
  scrollbar-width: thin;
}

.history-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-card);
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  transition: all var(--duration-fast) cubic-bezier(0.16, 1, 0.3, 1);
}

.history-card:hover {
  background: var(--paper-soft);
  border-color: var(--teal);
  box-shadow: var(--shadow-sm);
}

.history-card.active {
  background: var(--teal-soft);
  border-color: var(--teal);
}

.history-card.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--teal);
  border-radius: 0 2px 2px 0;
}

.history-card-left {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.history-type-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--teal);
}

.history-type-dot.video {
  background: #f59e0b;
}

.history-text-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}

.history-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.history-pub-date {
  font-weight: 500;
}

.history-dot-sep {
  opacity: 0.6;
}

.history-time-ago {
  color: var(--ink-light);
}

.history-remove-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
  border-radius: var(--radius-xs);
  transition: all var(--duration-fast) ease;
  line-height: 1;
}

.history-card:hover .history-remove-btn {
  opacity: 0.75;
}

.history-remove-btn:hover {
  opacity: 1 !important;
  color: var(--coral);
  background: var(--coral-soft);
}

.history-empty-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  padding: 16px 8px;
  background: var(--paper-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.history-empty-item .empty-icon {
  font-size: 16px;
  opacity: 0.6;
}

/* Preferences Modal - Account Card */
.prefs-account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.prefs-account-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.prefs-avatar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--surface-card);
  border: 1px solid var(--line);
  color: var(--teal);
}

.prefs-username {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  margin-right: 6px;
}

.prefs-role-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--surface-card);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

body[data-role="admin"] .prefs-role-badge {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: transparent;
}

.prefs-auth-action-btn {
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--surface-card);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.prefs-auth-action-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

/* History Settings in Prefs */
.prefs-history-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.prefs-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.prefs-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--teal);
  cursor: pointer;
}

/* User Management Panel (Admin Only) */
.admin-badge {
  background: var(--coral-soft);
  color: var(--coral);
}

.user-add-form {
  display: grid;
  grid-template-columns: 1fr 1fr 120px 90px;
  gap: 8px;
  margin: 12px 0 16px;
}

.user-add-form input,
.user-add-form select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  color: var(--ink);
  font-size: 12px;
  box-sizing: border-box;
}

.user-add-form input:focus,
.user-add-form select:focus {
  border-color: var(--teal);
  outline: none;
}

.user-add-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  border: none;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}

.user-add-btn:hover {
  background: #00707c;
}

.user-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.user-table th {
  background: var(--paper-soft);
  padding: 8px 10px;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}

.user-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.user-table tr:last-child td {
  border-bottom: none;
}

.user-action-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--surface-card);
  color: var(--ink-soft);
  cursor: pointer;
  margin-left: 6px;
  transition: all var(--duration-fast) ease;
}

.user-action-btn:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

.user-action-btn.danger {
  border-color: rgba(239, 68, 68, 0.35);
  background: var(--coral-soft);
  color: #d94f3d;
}

.user-action-btn.danger:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

/* ==========================================================================
   Login Modal
   ========================================================================== */
.login-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 26, 36, 0.45);
  backdrop-filter: blur(4px);
}

.login-container {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  z-index: 1;
}

.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.login-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.login-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: color var(--duration-fast) ease;
}

.login-close-btn:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form .form-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-form label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}

.login-form input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 13px;
}

.login-form input:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 2px var(--teal-soft);
}

.login-error-msg {
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  font-size: 12px;
}

.login-submit-btn {
  height: 36px;
  width: 100%;
  border-radius: var(--radius-xs);
  border: none;
  background: var(--teal);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
  margin-top: 4px;
}

.login-submit-btn:hover {
  background: #00707c;
}

/* ==========================================================================
   User Profile Modal / Popover Styles
   ========================================================================== */
.user-profile-modal {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-profile-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 26, 36, 0.4);
  backdrop-filter: blur(3px);
}

.user-profile-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  max-height: 88dvh;
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-sizing: border-box;
}

.user-profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.user-profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  flex-shrink: 0;
}

body[data-role="admin"] .user-profile-avatar {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: rgba(224, 90, 71, 0.3);
}

.user-profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.user-profile-username {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-profile-close {
  position: absolute;
  top: -4px;
  right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: color var(--duration-fast) ease;
}

.user-profile-close:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.user-profile-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  font-size: 12px;
}

.user-profile-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile-meta-row .meta-label {
  color: var(--muted);
}

.user-profile-meta-row .meta-val {
  font-weight: 500;
  color: var(--ink);
}

.user-profile-meta-row .meta-val.online {
  color: #10b981;
}

.user-profile-footer {
  display: flex;
  gap: 8px;
}

.user-profile-btn {
  flex: 1;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.user-profile-btn.secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface-card);
  color: var(--ink-soft);
}

.user-profile-btn.secondary:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.user-profile-btn.danger {
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}

.user-profile-btn.danger:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.user-profile-btn.full-width {
  width: 100%;
  flex: none;
}

/* ==========================================================================
   Range Sliders & Bottom User Creation Card Styles
   ========================================================================== */
.prefs-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.prefs-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--line-strong);
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
}

.prefs-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: grab;
  transition: transform var(--duration-fast) ease, background var(--duration-fast) ease;
}

.prefs-range-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.prefs-range-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: grab;
}

.prefs-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  padding: 0 2px;
}

/* User Management - Table & Bottom Form Card */
.user-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  overflow: hidden;
  max-height: 180px;
  overflow-y: auto;
  box-sizing: border-box;
  width: 100%;
}

.user-create-card {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  box-sizing: border-box;
  width: 100%;
}

.user-create-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.user-add-form-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 110px;
  gap: 6px;
  box-sizing: border-box;
  width: 100%;
}

.user-form-row input,
.user-form-row select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  color: var(--ink);
  font-size: 12px;
  box-sizing: border-box;
  width: 100%;
}

.user-form-row input:focus,
.user-form-row select:focus {
  border-color: var(--teal);
  outline: none;
}

.user-add-btn {
  height: 32px;
  width: 100%;
  border-radius: var(--radius-xs);
  border: none;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}

.user-add-btn:hover {
  background: #00707c;
}

/* ==========================================================================
   Batch Selection, LLM Configuration & AI Chat Workspace Styles
   ========================================================================== */

/* Topbar Batch Button Active State */
.topbar-actions .batch-btn.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
  box-shadow: 0 0 0 2px rgba(8, 126, 120, 0.2);
}

/* Floating Batch Action Bar */
.batch-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  margin: 0 auto 16px;
  animation: slideDown 0.2s ease-out;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--reading-max-width);
  transition: max-width 0.15s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.batch-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.batch-count-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.batch-count-badge strong {
  color: var(--teal);
  font-size: 14px;
}

.batch-words-hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: normal;
}

.batch-quick-range {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.range-label {
  font-size: 11.5px;
  color: var(--muted);
}

.batch-range-btn {
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--paper-soft);
  color: var(--ink-soft);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.batch-range-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

.batch-custom-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.batch-date-input {
  height: 26px;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 11px;
}

.range-sep {
  font-size: 11px;
  color: var(--muted);
}

.batch-apply-btn {
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.batch-apply-btn:hover {
  background: #00707c;
}

.batch-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.batch-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
}

.batch-action-btn.small {
  padding: 0 9px;
  font-size: 11.5px;
  height: 28px;
  gap: 4px;
}

.batch-action-btn.secondary {
  border: 1px solid var(--line-strong);
  background: var(--paper-soft);
  color: var(--ink);
}

.batch-action-btn.secondary:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.batch-action-btn.primary {
  border: none;
  background: var(--teal);
  color: #ffffff;
  box-shadow: var(--shadow-xs);
}

.batch-action-btn.primary:hover {
  background: #00707c;
}

.batch-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius-xs);
}

.batch-close-btn:hover {
  background: var(--paper-soft);
  color: var(--ink);
}

/* User Profile LLM Configuration Card */
.user-profile-llm-section {
  margin-top: 6px;
  padding: 12px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  box-sizing: border-box;
}

.llm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.llm-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.llm-status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(20, 29, 25, 0.08);
  color: var(--muted);
}

.llm-status-badge.connected {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.llm-status-badge.error {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.llm-config-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.llm-form-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.llm-form-item label {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
}

.llm-form-item input,
.llm-form-item select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  color: var(--ink);
  font-size: 11.5px;
  box-sizing: border-box;
  width: 100%;
}

.llm-form-item input:focus,
.llm-form-item select:focus {
  border-color: var(--teal);
  outline: none;
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrap input {
  padding-right: 28px;
}

.toggle-pwd-btn {
  position: absolute;
  right: 4px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
}

.llm-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.llm-btn {
  flex: 1;
  height: 30px;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.llm-btn.secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface-card);
  color: var(--ink-soft);
}

.llm-btn.secondary:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.llm-btn.primary {
  border: none;
  background: var(--teal);
  color: #ffffff;
}

.llm-btn.primary:hover {
  background: #00707c;
}

.llm-test-result {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  margin-top: 4px;
}

.llm-test-result.success {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.llm-test-result.fail {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ==========================================================================
   AI Research & Conversation Panel (3-Column Workspace)
   ========================================================================== */
.ai-research-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--line-strong);
  overflow: hidden;
  z-index: 25;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.05);
}

@media (max-width: 1279px) {
  .ai-research-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(480px, 100vw);
    height: 100vh;
    z-index: 1100;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.2);
  }
}

/* 1. Header & Conversation Switcher */
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--paper-soft);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.ai-conv-selector-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.ai-conv-switcher-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: all var(--duration-fast) ease;
}

.ai-conv-switcher-btn:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.ai-conv-title-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.ai-active-conv-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-active-conv-subtitle {
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chevron-down {
  color: var(--muted);
  flex-shrink: 0;
}

/* Conversation Popover Dropdown */
.ai-conv-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: 260px;
  max-height: 380px;
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}

.ai-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.ai-new-conv-header-btn {
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.ai-new-conv-header-btn:hover {
  background: var(--teal);
  color: #fff;
}

.ai-conv-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 4px 0;
  max-height: 320px;
}

.ai-conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  gap: 8px;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}

.ai-conv-item:hover {
  background: var(--paper-soft);
}

.ai-conv-item.active {
  background: var(--teal-soft);
}

.ai-conv-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.ai-conv-item-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-conv-dot {
  font-size: 8px;
  color: var(--muted);
}

.ai-conv-item.active .ai-conv-dot {
  color: var(--teal);
}

.ai-conv-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-conv-item.active .ai-conv-item-title {
  color: var(--teal);
}

.ai-conv-item-meta {
  font-size: 10px;
  color: var(--muted);
}

.ai-conv-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}

.ai-conv-item:hover .ai-conv-item-actions {
  opacity: 1;
}

.ai-conv-action-icon {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
  border-radius: var(--radius-xs);
}

.ai-conv-action-icon:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.05);
}

.ai-conv-action-icon.danger:hover {
  color: #ef4444;
}

/* Header Actions */
.ai-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ai-panel-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.ai-panel-tool-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

.ai-panel-tool-btn.close-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

/* 2. Research Scope Section (参考资料 Chips) */
.ai-scope-section {
  padding: 8px 14px;
  background: var(--paper-soft);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.ai-scope-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-scope-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-scope-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

.ai-scope-count {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 700;
}

.ai-scope-add-btn {
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px dashed var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-scope-add-btn:hover:not(.disabled) {
  background: var(--teal);
  color: #ffffff;
}

.ai-scope-add-btn.disabled {
  opacity: 0.65;
  cursor: default;
  border: 1px solid transparent;
  background: transparent;
  color: var(--teal);
}

.ai-scope-chips {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  max-height: 80px;
  overflow-y: auto;
}

.ai-scope-date-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 5px;
}

.ai-scope-date-input {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  color: var(--ink-soft);
  font-size: 10px;
}

.ai-scope-date-sep { color: var(--muted); font-size: 10px; }

.ai-scope-range-btn {
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--teal);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.ai-scope-range-btn:hover { background: var(--teal-soft); }
.ai-scope-range-btn.primary { background: var(--teal); color: #fff; }
.ai-scope-range-btn.primary:hover { background: var(--teal-hover); }

.ai-scope-budget {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.35;
}

.ai-scope-budget.over-budget { color: var(--gold); }
.ai-retrieval-status { margin-left: 6px; color: var(--muted); font-size: 10.5px; }
.ai-cite-pill.typed.article { border-color: rgba(201, 75, 86, 0.38); color: var(--evidence); }
.ai-cite-pill.typed.wiki { border-color: rgba(8, 126, 120, 0.38); color: var(--teal); }
.ai-cite-pill.typed.kline { border-color: rgba(184, 134, 45, 0.42); color: var(--gold); }
.ai-cite-pill.typed.quote { border-color: rgba(184, 134, 45, 0.58); color: var(--gold); }
.ai-cite-pill.typed.web { border-color: color-mix(in srgb, var(--web) 42%, transparent); color: var(--web); }
.llm-field-hint { color: var(--muted); font-size: 10.5px; line-height: 1.5; }

@media (max-width: 420px) {
  .ai-scope-date-row { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .ai-scope-range-btn { grid-column: span 1; }
  .ai-scope-range-btn:first-of-type { grid-column: 1 / 3; }
}

.scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  font-size: 11px;
  color: var(--ink);
  transition: all var(--duration-fast) ease;
}

.scope-chip:hover {
  border-color: var(--teal);
}

.chip-link-btn {
  background: none;
  border: none;
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-link-btn:hover {
  color: var(--teal);
  text-decoration: underline;
}

.chip-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1;
  border-radius: 50%;
}

.chip-remove-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.scope-empty-hint {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* 3. Messages Stream */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--paper);
}

.ai-welcome-card {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-welcome-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.ai-welcome-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.ai-welcome-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.ai-welcome-btn {
  text-align: left;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--paper-soft);
  color: var(--ink-soft);
  font-size: 11.5px;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.ai-welcome-btn:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

.ai-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 92%;
  animation: fadeIn 0.15s ease-out;
}

.ai-message.user {
  align-self: flex-end;
}

.ai-message.assistant {
  align-self: flex-start;
}

.ai-msg-content {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.65;
  box-sizing: border-box;
  word-break: break-word;
}

.ai-message.user .ai-msg-content {
  background: var(--teal);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.ai-message.assistant .ai-msg-content {
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  border-bottom-left-radius: 2px;
}

.ai-msg-content p { margin: 0 0 6px; }
.ai-msg-content p:last-child { margin-bottom: 0; }
.ai-msg-content ul, .ai-msg-content ol { margin: 4px 0; padding-left: 18px; }

/* Clickable Citation Pill in AI Message */
.ai-cite-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: var(--teal-soft);
  border: 1px solid rgba(8, 126, 120, 0.3);
  color: var(--teal);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  vertical-align: baseline;
  margin: 0 2px;
}

.ai-cite-pill:hover {
  background: var(--teal);
  color: #fff;
}

.ai-msg-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  opacity: 0.6;
  transition: opacity var(--duration-fast) ease;
}

.ai-message:hover .ai-msg-toolbar {
  opacity: 1;
}

.ai-msg-action-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10.5px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: var(--radius-xs);
}

.ai-msg-action-btn:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.ai-cursor {
  display: inline-block;
  width: 6px;
  height: 13px;
  background: var(--teal);
  margin-left: 2px;
  vertical-align: middle;
  animation: cursorBlink 0.8s infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 4. Footer & Input */
.ai-panel-footer {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  background: var(--paper-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.ai-presets-chips-row {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.preset-pill {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--ink-soft);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast) ease;
}

.preset-pill:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.preset-pill.active {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 600;
}

.ai-input-wrap {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  overflow: hidden;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.ai-input-wrap:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-soft);
}

.ai-chat-textarea {
  width: 100%;
  min-height: 54px;
  max-height: 140px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.5;
  resize: none;
  box-sizing: border-box;
  outline: none;
}

.ai-input-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 6px;
  background: var(--paper-soft);
  border-top: 1px solid var(--line);
}

.ai-input-model-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--muted);
}

.ai-tag-dot {
  font-size: 8px;
  color: var(--teal);
}
.ai-network-status { margin-left: 5px; padding-left: 7px; border-left: 1px solid var(--border); color: var(--muted); font-size: 10px; }
.ai-network-status[data-state="on"], .ai-network-status[data-state="ready"] { color: var(--teal); }
.ai-network-status[data-state="loading"] { color: var(--gold); }
.ai-network-status[data-state="error"] { color: var(--evidence); }

.ai-input-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-stop-btn {
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid #ef4444;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.ai-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  border: none;
  background: var(--teal);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}

.ai-send-btn:hover {
  background: #00707c;
}

/* 渐进载入：某天的文章尚未载入时，徽标半透明提示；载入后恢复正常 */
.sidebar-day-cell.has-records:not(.loaded) .day-badges {
  opacity: 0.55;
}
.sidebar-day-cell.loaded.has-records .day-badges {
  opacity: 1;
}

/* 字体风格示例按钮：放大字号让各字体差异可见 */
.pref-opt-btn.font-preview {
  font-size: 15px;
  letter-spacing: 0.5px;
}

/* 批量栏右侧：全量档案本地缓存状态提示 */
.batch-cache-info {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ==========================================================================
   评论区（抓取的 B 站评论：青哥发言置顶高亮）
   ========================================================================== */
.detail-comments {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.comments-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.comments-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  padding: 4px 0;
}
.comments-header:hover { color: var(--teal); }
.comments-chevron {
  font-size: 14px;
  color: var(--muted);
  transition: transform 0.2s ease;
}
.detail-comments.collapsed .comments-chevron { transform: rotate(-90deg); }
.detail-comments.collapsed .comments-list,
.detail-comments.collapsed .comments-bar-right { display: none !important; }

.comments-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.comment-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-size: 11.5px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.comment-refresh-btn:hover {
  color: var(--teal);
  border-color: var(--teal);
  background: var(--teal-soft);
}
.comment-refresh-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.comment-refresh-btn.loading svg {
  animation: spin 1s linear infinite;
}

.comments-sort-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.comment-sort-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 12px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s ease;
}
.comment-sort-btn:hover { color: var(--ink); }
.comment-sort-btn.active {
  color: var(--teal);
  font-weight: 700;
}
.comment-sort-divider {
  color: var(--line-strong);
  font-size: 11px;
  user-select: none;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 580px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(8, 126, 120, 0.28) transparent;
}

.comments-list::-webkit-scrollbar {
  width: 6px;
}
.comments-list::-webkit-scrollbar-track {
  background: transparent;
}
.comments-list::-webkit-scrollbar-thumb {
  background: rgba(8, 126, 120, 0.22);
  border-radius: 6px;
  transition: background var(--duration-fast) ease;
}
.comments-list::-webkit-scrollbar-thumb:hover {
  background: rgba(8, 126, 120, 0.45);
}

[data-theme="dark"] .comments-list {
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}
[data-theme="dark"] .comments-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
}
[data-theme="dark"] .comments-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.38);
}
.comment-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.comment-item:hover {
  background: var(--surface-hover);
}
.comment-item.is-up {
  border-left: 3.5px solid #fb7299;
  background: rgba(251, 114, 153, 0.04);
}
.comment-item.has-up-reply {
  border-left: 3.5px solid var(--teal);
}
.comment-item.is-deleted {
  opacity: 0.85;
}

.comment-main {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.comment-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}
.comment-user-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.comment-user {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.bili-up-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #fb7299;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.2;
}

.comment-deleted-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.3;
}

.comment-time {
  font-size: 11.5px;
  color: var(--muted);
  margin-left: auto;
}

.comment-message-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}
.comment-message-col,
.sub-message-col {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.comment-message {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-stats-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  user-select: none;
}
.comment-stat-item {
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

/* 二级评论区 (B站风格嵌套框) */
.comment-sub-box {
  margin-top: 8px;
  background: var(--surface-secondary);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sub-comment-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12.5px;
  line-height: 1.6;
}
.sub-time {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}
.sub-main {
  flex: 1;
  min-width: 0;
}
.sub-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}
.sub-user {
  font-weight: 600;
  color: var(--ink-light);
  font-size: 12px;
}
.sub-message-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}
.sub-message {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-soft);
  word-break: break-word;
  white-space: pre-wrap;
}

.sub-expand-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sub-expand-btn:hover {
  text-decoration: underline;
}

/* Comment User Avatars, Emotes & Image Cards */
.comment-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
}

.comment-user-avatar.sub {
  width: 20px;
  height: 20px;
}

.comment-user-avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.comment-emote {
  display: inline-block;
  vertical-align: -4px;
  width: 22px;
  height: 22px;
  object-fit: contain;
  margin: 0 1.5px;
}

.comment-pictures {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.comment-picture-card {
  position: relative;
  border-radius: var(--radius-xs, 6px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--paper-soft);
  cursor: zoom-in;
  transition: transform var(--duration-fast) ease, border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.comment-picture-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-sm);
  transform: scale(1.02);
}

.comment-picture-card img {
  display: block;
  max-width: 160px;
  max-height: 160px;
  width: auto;
  height: auto;
  object-fit: cover;
}

@media (max-width: 640px) {
  .comment-picture-card img {
    max-width: 120px;
    max-height: 120px;
  }
}

/* ==========================================================================
   高级搜索与检索过滤浮层（精美卡片化设计）
   ========================================================================== */
.search-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs, 4px);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--duration-fast) ease;
  padding: 0;
}
.search-settings-btn:hover,
.search-settings-btn[aria-expanded="true"] {
  background: var(--surface-subtle);
  color: var(--teal);
  border-color: var(--line);
}

.clear-search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--surface-subtle);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 4px;
  transition: all var(--duration-fast) ease;
  padding: 0;
}
.clear-search-btn:hover {
  background: var(--line-strong);
  color: var(--ink);
}

.search-settings-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 290px;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md, 10px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1200;
  backdrop-filter: blur(16px);
  animation: fadeInDown 0.18s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.search-popover-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.3px;
}

.search-pref-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-pref-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.search-select {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs, 6px);
  background: var(--surface-card);
  color: var(--ink);
  font-size: 12px;
  font-family: inherit;
  padding: 0 8px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--duration-fast) ease;
}
.search-select:focus {
  border-color: var(--teal);
}

.search-range-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: -2px;
}

.search-date-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs, 6px);
  background: var(--surface-card);
  color: var(--ink);
  font-size: 11.5px;
  font-family: inherit;
  padding: 0 6px;
  outline: none;
  transition: border-color var(--duration-fast) ease;
}
.search-date-input:focus {
  border-color: var(--teal);
}

.search-range-sep {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.search-scope-chips {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.search-scope-chip input[type="checkbox"] {
  accent-color: var(--teal);
  width: 14px;
  height: 14px;
  cursor: pointer;
  margin: 0;
}

[data-theme="dark"] .search-settings-popover {
  background: #18221d;
  border-color: #2a3b32;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .search-select,
[data-theme="dark"] .search-date-input {
  background: #141c18;
  border-color: #2e4036;
  color: #edf5ee;
}

[data-theme="dark"] .search-settings-btn:hover,
[data-theme="dark"] .search-settings-btn[aria-expanded="true"] {
  background: #23332a;
  color: #2dd4bf;
  border-color: #2e4036;
}

[data-theme="dark"] .clear-search-btn {
  background: #23332a;
  color: #9aa4ad;
}

[data-theme="dark"] .clear-search-btn:hover {
  background: #334a3d;
  color: #ffffff;
}

/* ==========================================================================
   收藏功能与侧边栏过滤胶囊样式
   ========================================================================== */
.type-dot.fav {
  background: #fa8c16;
}

.action-link.fav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.action-link.fav-btn.active {
  background: #fff7e6;
  color: #d46b08;
  border-color: #ffd591;
  font-weight: 600;
}
.action-link.fav-btn.active svg {
  fill: currentColor;
}
[data-theme="dark"] .action-link.fav-btn.active {
  background: #2b1d11;
  color: #ffc069;
  border-color: #874d00;
}

/* ==========================================================================
   多大模型配置管理器工具栏 (Multi-LLM Profiles)
   ========================================================================== */
.llm-profile-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 14px;
}
.llm-profile-select-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.llm-profile-select-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.llm-profile-select {
  flex: 1;
  min-width: 0;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  font-family: inherit;
  padding: 0 8px;
}
.llm-profile-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.llm-sub-btn {
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.llm-sub-btn:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal);
}
.llm-sub-btn.danger {
  color: var(--coral);
}
.llm-sub-btn.danger:hover:not(:disabled) {
  border-color: var(--coral);
  background: var(--coral-soft);
}
.llm-sub-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* AI Chat 工作台顶栏快速切换模型下拉框 */
.ai-quick-profile-wrap {
  display: flex;
  align-items: center;
}
.ai-quick-profile-select {
  height: 28px;
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  color: var(--ink);
  font-size: 11.5px;
  font-family: inherit;
  padding: 0 6px;
  max-width: 150px;
  cursor: pointer;
}
@media (max-width: 640px) {
  .ai-quick-profile-select {
    max-width: 100px;
  }
}
