/* ============================================
   Reader CSS — 文章草稿阅读系统
   ============================================ */

/* ---- CSS Variables ---- */
:root {
  --rdr-bg: #f5f6fa;
  --rdr-surface: #ffffff;
  --rdr-sidebar-bg: #fafbfd;
  --rdr-nav-bg: #1e293b;
  --rdr-nav-text: #e2e8f0;
  --rdr-primary: #2563eb;
  --rdr-primary-light: #dbeafe;
  --rdr-text: #1e293b;
  --rdr-text-secondary: #64748b;
  --rdr-border: #e2e8f0;
  --rdr-accent-green: #059669;
  --rdr-accent-orange: #ea580c;
  --rdr-radius: 8px;
  --rdr-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --rdr-shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --rdr-transition: 0.2s ease;
  --rdr-sidebar-width: 340px;
}

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ---- Body ---- */
.reader-body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC',
               'HarmonyOS Sans', 'Microsoft YaHei', sans-serif;
  background: var(--rdr-bg);
  color: var(--rdr-text);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Navbar ---- */
.rdr-navbar {
  height: 52px;
  background: var(--rdr-nav-bg);
  color: var(--rdr-nav-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.rdr-nav-left { display: flex; align-items: center; gap: 10px; }
.rdr-menu-toggle {
  display: none;
  background: none; border: none;
  color: var(--rdr-nav-text); font-size: 20px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; line-height: 1;
}
.rdr-menu-toggle:hover { background: rgba(255,255,255,0.1); }
.rdr-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--rdr-nav-text);
  font-weight: 600; font-size: 15px;
}
.rdr-logo:hover { color: #fff; }
.rdr-nav-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.rdr-nav-link { color: var(--rdr-nav-text); text-decoration: none; padding: 4px 10px; border-radius: 6px; }
.rdr-nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.rdr-nav-divider { color: #475569; }
.rdr-article-count { color: #94a3b8; font-weight: 500; }

/* ---- Layout ---- */
.rdr-layout { display: flex; height: calc(100vh - 52px); position: relative; }

/* ---- Sidebar ---- */
.rdr-sidebar {
  width: var(--rdr-sidebar-width);
  min-width: var(--rdr-sidebar-width);
  background: var(--rdr-sidebar-bg);
  border-right: 1px solid var(--rdr-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--rdr-transition);
  z-index: 50;
}
.rdr-sidebar-inner { display: flex; flex-direction: column; height: 100%; }

/* Search */
.rdr-search-box {
  position: relative;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}
.rdr-search-box input {
  width: 100%; padding: 9px 36px 9px 14px;
  border: 1.5px solid var(--rdr-border); border-radius: 20px;
  font-size: 13px; color: var(--rdr-text); outline: none;
  background: #fff; transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.rdr-search-box input:focus {
  border-color: var(--rdr-primary);
  box-shadow: 0 0 0 3px var(--rdr-primary-light);
}
.rdr-search-icon { position: absolute; right: 28px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: 0.4; pointer-events: none; }

/* Filter chips */
.rdr-filter-group {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}
.rdr-filter-chip {
  padding: 3px 10px; border: 1px solid var(--rdr-border);
  border-radius: 12px; font-size: 11px; cursor: pointer;
  background: #fff; color: var(--rdr-text-secondary);
  font-family: inherit; transition: all 0.15s;
  white-space: nowrap;
}
.rdr-filter-chip:hover { border-color: var(--rdr-primary); color: var(--rdr-primary); }
.rdr-filter-chip.active { background: var(--rdr-primary); color: #fff; border-color: var(--rdr-primary); }

/* Article list */
.rdr-list-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.rdr-list { display: flex; flex-direction: column; }
.rdr-list-loading, .rdr-list-empty, .rdr-list-error {
  padding: 24px; text-align: center; color: var(--rdr-text-secondary); font-size: 13px;
}

.rdr-list-item {
  padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--rdr-border);
  transition: background 0.15s;
}
.rdr-list-item:hover { background: var(--rdr-primary-light); }
.rdr-list-item.active { background: #eff6ff; border-left: 3px solid var(--rdr-primary); padding-left: 13px; }

.rdr-list-item-title {
  font-size: 13px; font-weight: 600; color: var(--rdr-text);
  line-height: 1.4; margin-bottom: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.rdr-list-item-meta { display: flex; gap: 5px; margin-bottom: 3px; }
.rdr-badge {
  display: inline-block; padding: 1px 7px; border-radius: 3px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
}
.rdr-badge-line { background: #dbeafe; color: #1d4ed8; }
.rdr-badge-sc { background: #f0fdf4; color: #166534; }
.rdr-list-item-stats { font-size: 11px; color: var(--rdr-text-secondary); }

/* ---- Main Content ---- */
.rdr-main {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  overscroll-behavior: contain;
}

.rdr-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--rdr-text-secondary);
  padding: 40px; text-align: center;
}
.rdr-empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.5; }
.rdr-empty h2 { font-size: 20px; font-weight: 700; color: var(--rdr-text); margin-bottom: 6px; }
.rdr-empty p { font-size: 14px; }

.rdr-loading {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
}
.rdr-spinner {
  width: 36px; height: 36px; border: 3px solid var(--rdr-border);
  border-top-color: var(--rdr-primary); border-radius: 50%;
  animation: rdrSpin 0.7s linear infinite;
}
@keyframes rdrSpin { to { transform: rotate(360deg); } }

.rdr-error {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: #dc2626; padding: 40px;
}
.rdr-error-icon { font-size: 44px; }
.rdr-retry-btn {
  padding: 8px 20px; background: var(--rdr-primary); color: #fff;
  border: none; border-radius: 20px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.rdr-retry-btn:hover { opacity: 0.9; }

/* ---- Stats Bar ---- */
.rdr-stats-bar {
  display: flex; flex-wrap: wrap; gap: 16px;
  padding: 12px 24px; background: #fff;
  border-bottom: 1px solid var(--rdr-border);
  position: sticky; top: 0; z-index: 10;
  flex-shrink: 0;
}
.rdr-stat-item { font-size: 12px; color: var(--rdr-text-secondary); display: flex; align-items: center; gap: 4px; }
.rdr-stat-item strong { color: var(--rdr-primary); font-weight: 700; }

/* ---- Article Content ---- */
.rdr-article-wrap { flex: 1; display: flex; flex-direction: column; }

.rdr-article { padding: 30px 40px 60px; max-width: 860px; margin: 0 auto; width: 100%; }

/* Inherit article styles — keep all original formatting */
.rdr-article * { max-width: 100%; }
.rdr-article img { max-width: 100%; height: auto; border-radius: 6px; margin: 16px 0; }
.rdr-article table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13px; }
.rdr-article table th, .rdr-article table td {
  border: 1px solid var(--rdr-border); padding: 8px 12px; text-align: left;
}
.rdr-article table th { background: #f8fafc; font-weight: 600; }
.rdr-article h2 { font-size: 20px; margin: 28px 0 14px; color: var(--rdr-primary); }
.rdr-article h3 { font-size: 16px; margin: 20px 0 10px; color: var(--rdr-text); }
.rdr-article p { margin-bottom: 14px; text-align: justify; }
.rdr-article a { color: var(--rdr-primary); text-decoration: underline; }
.rdr-article blockquote {
  border-left: 3px solid var(--rdr-primary); padding: 10px 18px;
  margin: 14px 0; background: var(--rdr-primary-light);
  color: #1e40af; font-size: 14px;
}
.rdr-article ul, .rdr-article ol { margin: 10px 0; padding-left: 22px; }
.rdr-article li { margin-bottom: 4px; }
.rdr-article code {
  background: #f1f5f9; padding: 2px 6px; border-radius: 3px;
  font-size: 13px; color: #c2410c;
}
.rdr-article pre {
  background: #1e293b; color: #e2e8f0; padding: 16px 20px;
  border-radius: 8px; overflow-x: auto; margin: 14px 0; font-size: 13px; line-height: 1.7;
}

/* ---- Toast ---- */
.rdr-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1e293b; color: #fff; padding: 10px 24px;
  border-radius: 20px; font-size: 13px; z-index: 999;
  opacity: 0; transition: all 0.3s ease;
  pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.rdr-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Overlay (mobile) ---- */
.rdr-overlay { display: none; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .rdr-menu-toggle { display: block; }
  .rdr-logo span { display: none; }

  .rdr-sidebar {
    position: fixed; top: 52px; left: 0; bottom: 0;
    transform: translateX(-100%); width: 280px; min-width: 280px;
    z-index: 60; box-shadow: var(--rdr-shadow-lg);
  }
  .rdr-sidebar.open { transform: translateX(0); }

  .rdr-overlay {
    display: block; position: fixed; inset: 0; top: 52px;
    background: rgba(0,0,0,0.35); z-index: 55;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
  }
  .rdr-overlay.show { opacity: 1; pointer-events: auto; }

  .rdr-article { padding: 20px 16px 40px; }
  .rdr-stats-bar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .rdr-stat-item { font-size: 11px; }
  .rdr-navbar { padding: 0 12px; }
}
