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

:root {
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e2e;
    --surface: #181825;
    --surface2: #313244;
    --primary: #89b4fa;
    --text: #cdd6f4;
    --text-dim: #a6adc8;
    --border: #45475a;
    --error: #f38ba8;
    --error-bg: #2a1a1a;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eff1f5;
    --surface: #e6e9ef;
    --surface2: #ccd0da;
    --primary: #1e66f5;
    --text: #4c4f69;
    --text-dim: #6c6f85;
    --border: #bcc0cc;
    --error: #d20f39;
    --error-bg: #f2d5d5;
  }
}

body {
  font-family: Arial, sans;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
}

a:hover {
  color: inherit;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

header {
  background: var(--surface);
  border: 2px solid var(--border);

  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.url-bar {
  flex: 1;
  display: flex;
  gap: 8px;
  min-width: 200px;
}

.url-bar input, .search-bar input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.url-bar input:focus, .search-bar input:focus {
  border-color: var(--primary);
}

select#proxy-select {
  padding: 4px 8px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
}

button, .btn, .secondary {
  padding: 8px 16px;
  background: var(--surface2);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

#breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

#breadcrumb .sep {
  margin: 0 4px;
}

.hidden { display: none !important; }

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 32px 0;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 0;
  color: var(--text-dim);
}

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

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

.error {
  background: var(--error-bg);
  border: 2px solid var(--error);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 16px 0;
  color: var(--error);
  font-size: 0.9rem;
}

.welcome {
  text-align: center;
  padding: 64px 16px;
}

.welcome p {
  color: var(--text-dim);
  margin-bottom: 8px;
}

.hint {
  margin-top: 24px;
  font-weight: 600;
}

.examples {
  list-style: none;
  margin-top: 12px;
}

.examples li {
  margin: 8px 0;
}

.examples a {
  font-size: 1rem;
}

.feed-header {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.feed-header h2 {
  font-size: 1.3rem;
}

.feed-header p {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 4px;
}

.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 8px 0 32px;
}

.nav-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  cursor: pointer;
  text-align: center;

  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-card:hover {
  background: var(--surface2);
  border-color: var(--primary);
}

.nav-card h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.nav-card p {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.entry-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.entry-cover {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.entry-cover .no-cover {
  font-size: 3rem;
  opacity: 0.3;
}

.entry-body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entry-body h3 {
  font-size: 0.95rem;
  line-height: 1.3;
}

.entry-body h3 a:hover {
  color: var(--primary);
}

.entry-authors {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.entry-summary {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  font-size: 0.75rem;
}

.entry-meta .tag {
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-dim);
}

.entry-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
}

.entry-actions a {
  flex: 1;
  text-align: center;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  background: var(--surface2);
  color: var(--text);
}

.entry-actions a.download {
  background: var(--primary);
  color: var(--bg);
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 32px;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

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

  .url-bar {
    min-width: unset;
  }

  .pagination {
    gap: 8px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  header {
    padding: 12px;
  }

  .header-top {
    gap: 8px;
  }

  .search-bar {
    margin-top: 8px;
    padding-top: 8px;
  }

  .feed-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .nav-card {
    padding: 16px 12px;
  }

  .nav-card .nav-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
  }

  .nav-card h3 {
    font-size: 0.9rem;
  }

  .nav-card p {
    font-size: 0.75rem;
  }

  .entry-body {
    padding: 8px;
  }

  .entry-body h3 {
    font-size: 0.85rem;
  }

  .entry-actions a {
    font-size: 0.7rem;
    padding: 6px 8px;
  }

  .entry-meta {
    gap: 4px;
  }

  .entry-meta .tag {
    font-size: 0.7rem;
    padding: 2px 6px;
  }

  .pagination {
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.8rem;
  }

  .pagination button {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .pagination .page-first,
  .pagination .page-last {
    display: none;
  }

  button, .btn, .secondary {
    min-height: 44px;
  }

  .entry-actions a {
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
