:root {
  --bg: #fafbfc;
  --panel: #ffffff;
  --muted: #6b7280;
  --text: #111827;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --chip: #eff6ff;
  --chip-text: #2c3a64;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg: #0f172a;
  --panel: #1e293b;
  --muted: #94a3b8;
  --text: #f8fafc;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --border: #334155;
  --border-light: #1e293b;
  --chip: rgba(59, 130, 246, 0.18);
  --chip-text: #dbeafe;
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand-section {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  font-size: 32px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.brand-text h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}

.brand-subtitle {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-section {
  display: flex;
  align-items: center;
  gap: 32px;
  flex: 1;
  justify-content: space-between;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--border-light);
  border-radius: 12px;
  padding: 8px;
}

.nav-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.date-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.date-label {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.search-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

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

button {
  background: var(--accent);
  border: none;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

button.secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.secondary:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

a {
  color: var(--accent);
  text-decoration: none;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-label {
  font-weight: 600;
}

.search {
  min-width: 300px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search::placeholder {
  color: var(--muted);
}

.reload-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.reload-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(90deg);
}

.revisions-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.toggle-text {
  transition: color 0.2s ease;
}

.revisions-toggle:hover .toggle-text {
  color: var(--accent);
}

.revisions-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

main {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.status {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: none;
  font-weight: 500;
  font-size: 14px;
  animation: slideIn 0.3s ease-out;
}

.status.info {
  background: var(--chip);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.status.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading States */
.loading-skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.card.skeleton {
  pointer-events: none;
}

.card.skeleton .thumb {
  background: var(--border-light);
  background-image: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

.card.skeleton .title {
  height: 24px;
  border-radius: 4px;
  margin-bottom: 12px;
  background: var(--border-light);
  background-image: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

.card.skeleton .summary {
  height: 16px;
  border-radius: 4px;
  margin-bottom: 8px;
  background: var(--border-light);
  background-image: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

.card.skeleton .summary:nth-child(2) {
  width: 80%;
}

.card.skeleton .summary:nth-child(3) {
  width: 60%;
}

.card.skeleton .metadata {
  height: 20px;
  border-radius: 4px;
  background: var(--border-light);
  background-image: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

/* Enhanced Button States */
button.loading {
  position: relative;
  color: transparent;
}

button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Success/Error States */
.copy-btn.success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.copy-btn.error {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

.toolbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 10px;
}

.spacer {
  flex: 1;
}

.filters {
  position: relative;
}


.theme-btn,
.export-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-right: 8px;
}

.theme-btn:hover,
.export-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

.theme-btn.dark {
  background: var(--accent);
  color: white;
}

.tag-btn {
  min-width: 90px;
}

.tag-panel {
  position: absolute;
  right: 0;
  top: 44px;
  width: 840px;
  max-height: 75vh;
  overflow: auto;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 10;
}

.hidden {
  display: none;
}

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

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

.tag-search {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.panel-toolbar {
  display: flex;
  gap: 8px;
  margin: 6px 0 8px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.tag-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 8px;
  padding: 6px 0;
}

.tag-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.3;
  justify-content: flex-start;
  cursor: pointer;
  padding: 2px 0;
}

.tag-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tag-count {
  background: var(--chip);
  color: var(--chip-text);
  border: 1px solid var(--border);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
}

.tag-list input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.tag-btn.active {
  background: var(--accent);
  color: white;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(340px, 380px));
    gap: 20px;
  }

  .header-content {
    padding: 16px 20px;
    gap: 24px;
  }

  .brand-text h1 {
    font-size: 22px;
  }

  .search {
    min-width: 250px;
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .brand-section {
    text-align: center;
  }

  .nav-section {
    flex-direction: column;
    gap: 16px;
  }

  .search-section {
    align-items: center;
  }

  .date-nav {
    justify-content: center;
  }

  .cards {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px 8px;
  }

  .main {
    padding: 16px;
  }

  .search {
    min-width: 200px;
  }

  .brand-text h1 {
    font-size: 20px;
  }

  .brand-icon {
    font-size: 28px;
  }
}

@media (max-width: 640px) {
  .tag-panel {
    width: calc(100vw - 24px);
    right: 12px;
    max-height: 70vh;
  }

  .tag-list {
    grid-template-columns: 1fr;
  }

  .search {
    min-width: 180px;
  }

  .pagination button {
    min-width: 80px;
    padding: 10px 16px;
  }

  #pageInfo {
    min-width: 100px;
    padding: 10px 16px;
  }
}

/* Print Styles */
@media print {

  .topbar,
  .toolbar,
  .pagination,
  .copy-btn {
    display: none !important;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .cards {
    display: block !important;
  }

  .card+.card {
    margin-top: 20px;
  }
}


.panel-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 420px));
  justify-content: center;
  gap: 24px;
  margin: 0 auto;
  padding: 24px 12px;
}

.cards .card {
  animation: fadeInUp 0.6s ease-out forwards;
  opacity: 0;
  transform: translateY(20px);
}

.cards .card:nth-child(1) {
  animation-delay: 0.1s;
}

.cards .card:nth-child(2) {
  animation-delay: 0.2s;
}

.cards .card:nth-child(3) {
  animation-delay: 0.3s;
}

.cards .card:nth-child(4) {
  animation-delay: 0.4s;
}

.cards .card:nth-child(5) {
  animation-delay: 0.5s;
}

.cards .card:nth-child(6) {
  animation-delay: 0.6s;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(37, 99, 235, 0.2);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover::before {
  opacity: 1;
}

.card .thumb {
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: top;
  background: #f2f4ff;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease;
}

.card .thumb:hover {
  filter: brightness(0.97);
}

.card .body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.title {
  margin: 0;
  font-size: 20px;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s ease;
  display: block;
}

.title a:hover {
  color: var(--accent);
}

.summary-container {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  position: relative;
}

.summary {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  flex: 1;
  text-align: justify;
}

.copy-btn {
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
  transition: all 0.2s ease;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.copy-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.copy-btn:hover {
  color: white;
  border-color: var(--accent);
  transform: scale(1.05);
}

.copy-btn:hover::before {
  opacity: 1;
}

.copy-btn:active {
  transform: scale(0.95);
}

.metadata {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.metadata .category {
  color: var(--accent);
  font-weight: 600;
  background: var(--chip);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.metadata .category:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
}

.metadata .separator {
  color: var(--border);
  font-size: 16px;
  font-weight: 300;
}

.metadata .date {
  color: var(--muted);
  background: var(--border-light);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 500;
}

.dot::before {
  content: '•';
  color: var(--muted);
  margin: 0 4px;
}

.footer {
  padding: 12px 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  background: var(--chip);
  color: var(--chip-text);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.links {
  display: none;
}

.pagination {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin: 32px 0;
  padding: 24px 0;
}

.pagination button {
  min-width: 100px;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

#pageInfo {
  background: var(--border-light);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  min-width: 120px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}