:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #293548;
  --border: #334155;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: rgba(30, 41, 59, 0.95);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
}

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

.logo-img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.badge-offline {
  background: var(--red);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.hidden {
  display: none !important;
}

/* ── Stats ── */
.stats-bar {
  max-width: 900px;
  margin: 10px auto 0;
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-new {
  color: var(--green);
}

/* ── Filters ── */
.filter-bar {
  max-width: 900px;
  margin: 10px auto 0;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.83rem;
  transition: all 0.18s;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Search ── */
.search-bar {
  max-width: 900px;
  margin: 10px auto 0;
}

#search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus {
  border-color: var(--primary);
}

/* ── Main list ── */
main {
  max-width: 900px;
  margin: 20px auto;
  padding: 0 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 0;
  color: var(--text-muted);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Paper card ── */
.paper-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.paper-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.paper-card.is-read {
  opacity: 0.55;
}

.paper-card.is-bookmarked {
  border-left: 3px solid var(--yellow);
}

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

.card-title {
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text);
  text-decoration: none;
  flex: 1;
}

.card-title:hover {
  color: #a5b4fc;
}

.card-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.action-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.action-btn.bookmarked {
  color: var(--yellow);
  border-color: var(--yellow);
}

.action-btn.read {
  color: var(--green);
  border-color: var(--green);
}

/* Card meta */
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.card-authors {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-date {
  font-size: 0.74rem;
  color: var(--text-dim);
}

.badge-new {
  background: var(--green);
  color: #fff;
  font-size: 0.64rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Tags */
.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.tag {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 6px;
}

.tag-category {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
}

.tag-keyword {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}

/* Summary */
.card-summary {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.card-summary.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.expand-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 5px 0 0;
  display: block;
}

.expand-btn:hover {
  text-decoration: underline;
}

/* ── Empty / error state ── */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 14px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  z-index: 200;
  white-space: nowrap;
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  h1 {
    font-size: 1rem;
  }

  .paper-card {
    padding: 14px 15px;
  }

  .card-title {
    font-size: 0.9rem;
  }

  .filter-btn {
    font-size: 0.78rem;
    padding: 4px 11px;
  }
}
