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

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

:root {
  --color-bg: #fafafa;
  --color-bg-hover: #f0f0f0;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-alpha: rgba(37, 99, 235, 0.2);
  --color-text: #1f2937;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-danger: #dc2626;
  --color-warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --radius: 8px;
  --max-width: 800px;
}

[data-theme="dark"] {
  --color-bg: #111827;
  --color-bg-hover: #374151;
  --color-surface: #1f2937;
  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-alpha: rgba(59, 130, 246, 0.3);
  --color-text: #f9fafb;
  --color-text-secondary: #9ca3af;
  --color-border: #374151;
  --color-danger: #ef4444;
  --color-warning: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Header */
.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.app-header h1 abbr {
  text-decoration: none;
  cursor: help;
}

.app-header h1 abbr:hover {
  text-decoration: underline dotted;
  text-decoration-color: var(--color-text-secondary);
  text-underline-offset: 4px;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
  }

  .app-header h1 {
    margin-bottom: 0;
  }
}

/* Search bar */
.search-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 0;
}

.search-bar input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1rem;
}

.search-bar input::placeholder {
  color: var(--color-text-secondary);
}

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

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--color-bg);
}

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

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

.btn-danger {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger);
  color: white;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1rem;
}

.btn-icon {
  padding: 0.5rem;
  min-width: 2.5rem;
  font-size: 1.125rem;
  line-height: 1;
}

/* App layout */
.app-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
}

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 1rem;
  position: sticky;
  top: 80px;
  display: none;
  align-self: flex-start;
}

@media (min-width: 900px) {
  .sidebar {
    display: block;
  }
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.sidebar-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}

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

.author-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.875rem;
  cursor: pointer;
}

.author-filter input {
  cursor: pointer;
}

.month-nav {
  max-height: 300px;
  overflow-y: auto;
}

.month-link {
  display: block;
  padding: 0.375rem 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: color 0.15s ease;
}

.month-link:hover {
  color: var(--color-primary);
}

.month-link.active {
  color: var(--color-primary);
  font-weight: 500;
}

/* Main content */
#main-content {
  flex: 1;
  min-width: 0;
  max-width: var(--max-width);
  padding: 1rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  font-size: 1.125rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  line-height: 1;
}

.modal-body {
  padding: 1rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
}

.checkbox-label input {
  cursor: pointer;
}

/* Feed list */
.feed-item-wrapper {
  position: relative;
  margin-bottom: 0.75rem;
}

a.feed-item {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  padding-bottom: 2.5rem;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
  text-decoration: none;
  color: inherit;
}

.feed-item:hover {
  box-shadow: var(--shadow-md);
}

.star-btn {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.15s ease, transform 0.15s ease;
}

.star-btn:hover {
  transform: scale(1.2);
}

.star-btn.starred {
  color: #f59e0b;
}

.feed-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.feed-item-feed {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.feed-item-date {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.month-separator {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 1rem 0 0.5rem;
  margin-top: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.month-separator:first-child {
  margin-top: 0;
  padding-top: 0;
}

.feed-item-title {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.feed-item-meta {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.feed-item-description {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Article view */
.article-view {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  cursor: pointer;
}

.article-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.article-meta {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.article-description {
  margin-bottom: 2rem;
  line-height: 1.8;
}

.article-action {
  text-align: center;
}

/* Manage feeds */
.manage-feed-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.manage-feed-color {
  position: relative;
  flex-shrink: 0;
}

.manage-feed-color .color-picker {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  background: none;
}

.manage-feed-color .color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.manage-feed-color .color-picker::-webkit-color-swatch {
  border-radius: 4px;
  border: none;
}

.manage-feed-color .color-reset {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: none;
  background: var(--color-text-secondary);
  color: var(--color-surface);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.manage-feed-color .color-reset:hover {
  background: var(--color-danger);
}

.color-swatch-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.color-swatch-btn:hover {
  transform: scale(1.1);
}

.color-palette {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 10;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.375rem;
  min-width: 140px;
}

.color-palette.open {
  display: grid;
}

.palette-color {
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.palette-color:hover {
  transform: scale(1.15);
}

.palette-color.selected {
  border-color: var(--color-text);
  box-shadow: 0 0 0 2px var(--color-surface);
}

.manage-feed-info {
  flex: 1;
  min-width: 0;
}

.manage-feed-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.manage-feed-url {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.manage-feed-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: 0.5rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-secondary);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-secondary);
}

.empty-state h3 {
  margin-bottom: 0.5rem;
  color: var(--color-text);
}
