/* YouNews - Mobile-First PWA Styles */

/* ============================================
   Theme Variables
   ============================================ */

:root {
  /* Brand colors (constant) */
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --primary-hover: #2563EB;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --danger: #EF4444;

  /* Default: Dark theme */
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f3460;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0a0;
  --text-muted: #6b7280;
  --border: #2a2a4e;
  --border-color: #2a2a4e;
  --surface-primary: #16213e;
  --surface-secondary: #1a1a2e;
  --surface-tertiary: #0f3460;
}

/* Light Theme */
[data-theme="light"] {
  --bg-dark: #f5f5f7;
  --bg-card: #ffffff;
  --bg-input: #f0f0f5;
  --text-primary: #1a1a2e;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --border-color: #e5e7eb;
  --surface-primary: #ffffff;
  --surface-secondary: #f5f5f7;
  --surface-tertiary: #e5e7eb;
}

/* Auto theme based on system preference */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-dark: #f5f5f7;
    --bg-card: #ffffff;
    --bg-input: #f0f0f5;
    --text-primary: #1a1a2e;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-color: #e5e7eb;
    --surface-primary: #ffffff;
    --surface-secondary: #f5f5f7;
    --surface-tertiary: #e5e7eb;
  }
}

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

/* ============================================
   Focus & Accessibility
   ============================================ */

/* Remove default outline for mouse users, keep for keyboard */
:focus {
  outline: none;
}

/* Visible focus for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Custom focus ring for buttons and links */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Skip to main content link (for keyboard users) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  z-index: 10000;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 1rem;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Container */
.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
.header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
}

.header-center {
  display: flex;
  justify-content: center;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

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

.form-label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

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

textarea.form-input {
  min-height: 100px;
  resize: vertical;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

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

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* iOS-style Back Button */
.back-button {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: #60A5FA !important;
  text-decoration: none !important;
  font-size: 1rem;
  font-weight: 500;
  transition: opacity 0.15s ease;
}

.back-button:link,
.back-button:visited,
.back-button:active,
.back-button:focus {
  color: #60A5FA !important;
  text-decoration: none !important;
}

.back-button:hover {
  color: #60A5FA !important;
  opacity: 0.7;
}

.back-button svg {
  flex-shrink: 0;
  stroke: #60A5FA !important;
}

.back-button span {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .back-button span {
    max-width: 80px;
  }
}

/* Select */
.form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
}

/* URL Preview (legacy) */
.url-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-input);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.url-preview-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
}

.url-preview-domain {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.url-preview-title {
  font-weight: 500;
  word-break: break-word;
}

/* Live Preview Card */
.preview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.preview-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  color: var(--text-secondary);
}

#previewContent {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  padding: 1rem;
}

.preview-image {
  flex-shrink: 0;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-input);
}

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

.preview-body {
  flex: 1;
  min-width: 0;
}

.preview-domain {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.preview-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Messages */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

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

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

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid #f59e0b;
  color: #f59e0b;
}

/* Duplicate URL Alert */
.duplicate-alert {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.duplicate-alert-icon {
  flex-shrink: 0;
}

.duplicate-alert-content {
  flex: 1;
}

.duplicate-alert-content strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #fbbf24;
}

.duplicate-alert-content p {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  opacity: 0.9;
}

.duplicate-item-link {
  display: block;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duplicate-item-link:hover {
  background: rgba(0, 0, 0, 0.3);
}

.duplicate-alert-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.spinner {
  width: 24px;
  height: 24px;
  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); }
}

/* Capture Page Specific */
.capture-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.capture-header {
  padding: 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.capture-content {
  flex: 1;
  padding: 1rem;
}

.capture-actions {
  padding: 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
}

/* Journal Selector */
.journal-header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.journal-selector {
  flex: 1;
}

.journal-name {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--text-primary);
  flex: 1;
}

.journal-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.journal-actions .btn {
  min-width: 36px;
  height: 36px;
  padding: 0.5rem;
}

.journal-actions .btn svg {
  width: 18px;
  height: 18px;
}

/* Status Tabs */
.status-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.status-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab:hover {
  background: var(--bg-input);
}

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

.tab .badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
}

.tab.active .badge {
  background: rgba(255, 255, 255, 0.3);
}

/* Link Cards */
.items-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .items-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

.link-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

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

.link-card.has-image {
  /* Cards with images have vertical layout */
}

.link-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-input);
}

.link-image > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.link-card:hover .link-image > img {
  transform: scale(1.05);
}

/* Favicon fallback when thumbnail is broken */
.image-favicon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.image-favicon-fallback img {
  border-radius: 4px;
}

.link-image.image-broken .source-icon-overlay {
  display: none;
}

/* Source icon overlay on images */
.source-icon-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.source-icon-overlay svg,
.source-icon-overlay img {
  width: 18px;
  height: 18px;
  color: white;
}

.source-icon-overlay img {
  border-radius: 2px;
}

/* Duration overlay on images (YouTube-style) */
.duration-overlay {
  position: absolute;
  bottom: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

/* Source icon inline (for cards without images) */
.source-icon-inline {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  opacity: 0.7;
  vertical-align: middle;
}

.source-icon-inline svg,
.source-icon-inline img {
  width: 14px;
  height: 14px;
}

.source-icon-inline img {
  border-radius: 2px;
}

/* Date inline next to domain */
.link-date-inline {
  color: var(--text-secondary);
  opacity: 0.8;
}

/* Video duration badge */
.link-duration {
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.link-card-main {
  flex: 1;
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  min-width: 0;
}

.link-favicon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2px;
}

.link-favicon img,
.link-favicon svg {
  width: 24px;
  height: 24px;
  border-radius: 4px;
}

.link-content {
  width: 100%;
  min-width: 0;
}

.link-domain {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.link-domain img,
.link-domain svg {
  flex-shrink: 0;
}

.link-title {
  display: block;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.link-description {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-snippet {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-score-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.375rem;
  margin-left: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--primary);
  background: rgba(102, 187, 106, 0.15);
  border-radius: 4px;
}

/* Search snippet in link-card */
.link-snippet {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.link-note {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-input);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.link-card-bottom {
  display: flex;
  align-items: stretch;
}

.link-actions {
  display: flex;
  flex-direction: row;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.action-form {
  display: contents;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:last-child {
  border-right: none;
}

.action-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.action-btn.action-publish:hover {
  color: var(--success);
}

.action-btn.action-delete:hover {
  color: var(--error);
}

.action-btn.action-highlight {
  color: var(--text-secondary);
}

.action-btn.action-highlight:hover {
  color: #eab308;
}

.action-btn.action-highlight.highlighted {
  color: #eab308;
}

.action-btn.action-highlight.highlighted:hover {
  color: var(--text-secondary);
}

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

.empty-icon {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-title {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-description {
  font-size: 0.875rem;
  max-width: 280px;
  margin: 0 auto;
}

/* Hide on Mobile */
.hide-mobile {
  display: none;
}

/* Responsive */
@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }

  .card {
    padding: 2rem;
  }

  .hide-mobile {
    display: inline;
  }
}


/* Journal Header */
.journal-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.journal-description {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.journal-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.journal-visibility {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.journal-visibility.public {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.journal-visibility.unlisted {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

/* Share Section */
.share-section {
  margin-top: 2rem;
  text-align: center;
}

/* Discover Page */
.discover-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .discover-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.journal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
  text-decoration: none;
  display: block;
}

.journal-card:hover {
  border-color: var(--primary);
}

.journal-card-image {
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--bg-dark);
}

.journal-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.journal-card-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-card) 100%);
  color: var(--text-secondary);
}

.journal-card-initial {
  font-size: 4rem;
  font-weight: 700;
  color: var(--primary);
  opacity: 0.5;
}

.journal-card-item-title {
  padding: 0.75rem 1rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.journal-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.journal-card-logo {
  width: 144px;
  height: 144px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.journal-card-logo-small {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.journal-card-logo-placeholder {
  width: 144px;
  height: 144px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 600;
  flex-shrink: 0;
}

.journal-card-logo-placeholder-small {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.journal-card-info {
  flex: 1;
  min-width: 0;
}

.journal-card-name {
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text-primary);
}

.journal-card-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.journal-card-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Journal Settings */
.slug-display {
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.875rem;
  word-break: break-all;
}

.slug-prefix {
  color: var(--text-secondary);
}

.slug-value {
  color: var(--primary);
  font-weight: 500;
}

.visibility-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg-input);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.visibility-option:hover {
  background: var(--border);
}

.visibility-option input[type="radio"] {
  margin-top: 0.25rem;
  accent-color: var(--primary);
}

.visibility-content {
  flex: 1;
}

.visibility-label {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.visibility-description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.public-link-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.public-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border-radius: 8px;
}

.public-link a {
  flex: 1;
  color: var(--primary);
  text-decoration: none;
  font-family: monospace;
}

.public-link a:hover {
  text-decoration: underline;
}

/* Safe area for mobile notch */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: calc(1rem + env(safe-area-inset-top));
  }

  .capture-actions {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* Tag chips for AI suggestions */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-chip:hover {
  background: var(--bg-card);
  border-color: var(--primary);
  color: var(--primary);
}

.tag-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.tag-chip.selected:hover {
  background: var(--primary-dark, #2563eb);
}

/* Tag badges for inbox cards */
.link-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.tag-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--primary);
  border-radius: 4px;
}

/* Clickable tag badges */
a.tag-badge {
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

a.tag-badge:hover {
  background: rgba(59, 130, 246, 0.25);
  transform: scale(1.05);
}

/* Journal badge for "Todos os Journals" view */
.journal-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  margin-right: -0.25rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--primary);
  border-radius: 4px;
  margin-right: 0.5rem;
}

.link-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.link-meta .link-tags {
  margin-top: 0;
}

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

/* Journal selector with add button */
.journal-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

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

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

/* URL copy row */
.url-copy-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.url-display {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-primary);
  word-break: break-all;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* ============================================
   Home Link & PWA Bottom Navigation
   ============================================ */

/* Home link in header */
.home-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.15s ease;
  margin-right: 0.75rem;
}

.home-link:hover {
  background: var(--bg-input);
  color: var(--primary);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0;
  z-index: 1000;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.625rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item:hover,
.nav-item.active {
  color: var(--primary);
}

.nav-item.active svg {
  stroke-width: 2.5;
}

/* Add padding to main content for bottom nav */
.container {
  padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
}


/* ============================================
   Home Page Styles
   ============================================ */

.home-greeting {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.home-subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

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

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-link {
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
}

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

/* Journal Preview Card */
.journal-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1rem;
  overflow: hidden;
}

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

.journal-preview-name {
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
}

.journal-preview-name:hover {
  color: var(--primary);
}

.journal-preview-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.journal-config-btn {
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.journal-config-btn:hover {
  color: var(--text-primary);
  background: var(--bg-input);
}

.journal-preview-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.journal-preview-items {
  display: flex;
  flex-direction: column;
}

.preview-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s ease;
}

.preview-item:last-child {
  border-bottom: none;
}

.preview-item:hover {
  background: var(--bg-input);
}

.preview-item-image {
  position: relative;
  flex-shrink: 0;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-input);
}

.preview-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item-content {
  flex: 1;
  min-width: 0;
}

.preview-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

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

.preview-item-date {
  font-size: 0.7rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

.preview-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.tag-badge-sm {
  display: inline-block;
  padding: 0.0625rem 0.375rem;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--primary);
  border-radius: 3px;
}

.journal-preview-footer {
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  text-align: center;
}

.journal-preview-footer a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.journal-preview-footer a:hover {
  text-decoration: underline;
}

/* Chronological Feed */
.chronological-feed {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.feed-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s ease;
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-item:hover {
  background: var(--bg-input);
}

.feed-item-image {
  position: relative;
  flex-shrink: 0;
  width: 100px;
  height: 75px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-input);
}

.feed-item-image > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed-item-favicon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.feed-item-favicon img {
  border-radius: 4px;
}

.feed-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.feed-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

.feed-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.journal-badge {
  display: inline-block;
  padding: 0.0625rem 0.375rem;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  border-radius: 3px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.feed-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.feed-item-tags .tag-badge-sm {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Feed responsivo - Mobile */
@media (max-width: 480px) {
  .feed-item {
    flex-direction: column;
    gap: 0.5rem;
  }

  .feed-item-image {
    width: 100%;
    height: 160px;
    border-radius: 8px;
  }

  .feed-item-title {
    font-size: 0.9375rem;
    -webkit-line-clamp: 3;
  }

  .feed-item-meta {
    gap: 0.375rem;
  }

  .journal-badge {
    max-width: 100px;
  }
}

/* Feed responsivo - Tablet/Desktop */
@media (min-width: 768px) {
  .feed-item-image {
    width: 140px;
    height: 95px;
  }

  .feed-item-title {
    font-size: 1rem;
  }

  .journal-badge {
    max-width: 150px;
  }
}

.empty-feed {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* Quick Stats */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Add New Journal Button */
.add-journal-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
}

.add-journal-card:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ============================================
   Responsive Layout - Sidebar & Bottom Nav
   ============================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Desktop Sidebar - Hidden on mobile by default */
.sidebar {
  display: none;
  flex-direction: column;
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.125rem;
}

.sidebar-logo svg {
  color: var(--text-primary);
}

.logo-accent {
  color: var(--primary);
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.15s ease;
  font-size: 0.9375rem;
}

.sidebar-item:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--primary);
  color: white;
}

.sidebar-item.active svg {
  color: white;
}

.sidebar-item svg {
  flex-shrink: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar-toggle .sidebar-arrow {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.sidebar-toggle.open .sidebar-arrow {
  transform: rotate(90deg);
}

.sidebar-submenu {
  display: none;
  flex-direction: column;
}

.sidebar-toggle.open + .sidebar-submenu {
  display: flex;
}

.sidebar-subitem {
  padding-left: 2.75rem;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

/* Install PWA Button (Desktop Sidebar) */
.install-btn {
  background: var(--success);
  color: white;
  border: none;
  cursor: pointer;
  width: 100%;
  margin-bottom: 0.5rem;
}

.install-btn:hover {
  background: #059669;
  color: white;
}

.install-btn svg {
  color: white;
}

/* Install PWA Banner (Mobile) */
.install-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--success);
  color: white;
  font-size: 0.875rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.install-banner-btn {
  background: white;
  color: var(--success);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.install-banner-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

/* Hide banner on desktop (sidebar has install button) */
@media (min-width: 768px) {
  .install-banner {
    display: none !important;
  }
}

/* Main Content Area */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Desktop Styles */
@media (min-width: 768px) {
  /* Show sidebar on desktop */
  .sidebar {
    display: flex;
  }

  /* Offset main content for sidebar */
  .main-area {
    margin-left: 240px;
  }

  /* Hide bottom nav on desktop */
  .bottom-nav {
    display: none;
  }

  /* Hide home link in header on desktop (sidebar has logo) */
  .home-link {
    display: none;
  }

  /* Remove bottom padding on desktop (no bottom nav) */
  .container {
    padding-bottom: 2rem;
  }
}

/* ============================================
   Journal Search
   ============================================ */

.journal-search {
  margin-bottom: 1.5rem;
}

.journal-search-form {
  width: 100%;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.25rem 0.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-input-wrapper .search-icon {
  margin: 0 0.5rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.journal-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  padding: 0.625rem 0.5rem;
  color: var(--text-primary);
  outline: none;
}

.journal-search-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.journal-search-btn {
  background: var(--primary);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.journal-search-btn:hover {
  background: var(--primary-dark);
}

.journal-search-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   Search Page
   ============================================ */

.search-form {
  margin-bottom: 1.5rem;
}

.search-filters {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.search-filters .form-select {
  width: auto;
  min-width: 200px;
}

.search-filter-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-chip:hover {
  border-color: var(--accent);
}

.filter-chip input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.filter-chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.results-count {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  transition: border-color 0.2s;
}

.result-card:hover {
  border-color: var(--primary);
}

.result-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.result-score {
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.result-meta {
  flex: 1;
  min-width: 0;
}

.result-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.result-title a {
  color: var(--text-primary);
  text-decoration: none;
}

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

.result-url {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
  margin-top: 0.25rem;
  word-break: break-all;
}

.result-snippet {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.empty-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  opacity: 0.8;
  margin-top: 0.5rem;
}

.search-hints {
  color: var(--text-secondary);
}

.search-hints h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--text-primary);
}

.search-hints ul {
  margin: 0;
  padding-left: 1.5rem;
}

.search-hints li {
  margin: 0.5rem 0;
}

/* ============================================
   Header Search (Inbox contextual search)
   ============================================ */

.header-search-form {
  width: 100%;
  max-width: 100%;
}

/* Hide header-left when search is present */
.header:has(.header-search-form) .header-left {
  display: none;
}

.header:has(.header-search-form) .header-center {
  flex: 1;
}

/* Desktop: show header-left alongside search */
@media (min-width: 768px) {
  .header:has(.header-search-form) .header-left {
    display: flex;
  }

  .header-search-form {
    max-width: 400px;
  }

  .header:has(.header-search-form) .header-center {
    flex: initial;
  }
}

/* ============================================
   Utility Classes
   ============================================ */

/* Visibility */
.is-hidden {
  display: none !important;
}

.is-visible {
  display: block !important;
}

/* Screen reader only - visually hidden but accessible */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Spacing utilities */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Text utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }

/* Flex utilities */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0) + 80px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: calc(100vw - 2rem);
  width: 100%;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: toast-enter 0.25s ease-out;
  pointer-events: auto;
}

.toast-exit {
  animation: toast-exit 0.2s ease-in forwards;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-exit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
}

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-message {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.toast-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Toast types */
.toast-success {
  border-left: 3px solid var(--success);
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error {
  border-left: 3px solid var(--error);
}

.toast-error .toast-icon {
  color: var(--error);
}

.toast-warning {
  border-left: 3px solid var(--warning);
}

.toast-warning .toast-icon {
  color: var(--warning);
}

.toast-info {
  border-left: 3px solid var(--primary);
}

.toast-info .toast-icon {
  color: var(--primary);
}

/* Clickable toast */
.toast-clickable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.toast-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

/* Toast action button */
.toast-action {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.25);
}

.toast-warning .toast-action {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
}

.toast-warning .toast-action:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* Desktop: position top-right */
@media (min-width: 768px) {
  .toast-container {
    bottom: auto;
    top: 1rem;
    left: auto;
    right: 1rem;
    transform: none;
  }
}

/* ============================================
   Theme Toggle
   ============================================ */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg-input);
  border-radius: 8px;
}

.theme-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.theme-toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.theme-toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle-switch.active {
  background: var(--primary);
}

.theme-toggle-switch.active::after {
  transform: translateX(22px);
}

/* Theme icons in toggle */
.theme-toggle-icons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.theme-icon:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.theme-icon.active {
  background: var(--primary);
  color: white;
}

/* Mobile bottom nav theme indicator */
.nav-item .theme-indicator {
  display: none;
}

/* Theme selector in config page */
.theme-selector {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.theme-selector-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.theme-options {
  display: flex;
  gap: 0.5rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
  flex: 1;
}

.theme-option:hover {
  border-color: var(--primary);
  color: var(--text-primary);
}

.theme-option.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

.theme-option span {
  font-size: 0.8125rem;
  font-weight: 500;
}

@media (max-width: 480px) {
  .theme-option {
    padding: 0.75rem 1rem;
  }

  .theme-option span {
    font-size: 0.75rem;
  }
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.progress-container {
  margin-top: 1rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.progress-text.progress-error {
  color: var(--danger);
}

.progress-text.progress-success {
  color: var(--success);
}

/* ==========================================================================
   Tags Management
   ========================================================================== */

.tags-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.tag-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tag-color {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-name {
  font-weight: 500;
}

.tag-usage {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.tag-auto-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  background: var(--bg-input);
  border-radius: 4px;
  color: var(--text-secondary);
}

.tag-actions {
  display: flex;
  gap: 0.25rem;
}

/* Color presets for tag editor */
.color-presets {
  display: flex;
  gap: 0.25rem;
}

.color-preset {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-preset:hover {
  border-color: var(--text-primary);
}

/* ============================================================================
   View Mode Toggle (shared between inbox and search)
   ============================================================================ */
.view-mode-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.view-mode-toggle {
  display: flex;
  gap: 0.25rem;
}

.view-mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.view-mode-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

/* ============================================================================
   Compact View Mode (shared between inbox and search)
   ============================================================================ */
.items-list.compact-view {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.items-list.compact-view .swipe-container {
  border-radius: 0;
  margin: 0;
}

.items-list.compact-view .link-card {
  flex-direction: row !important;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  position: relative;
}

/* Compact image */
.items-list.compact-view .link-image {
  flex-shrink: 0;
  width: 120px;
  height: 80px;
  aspect-ratio: auto;
  border-radius: 6px;
  order: -1;
}

.items-list.compact-view .link-image img {
  border-radius: 6px;
}

/* Hide source icon overlay in compact mode */
.items-list.compact-view .source-icon-overlay {
  display: none;
}

/* Content area */
.items-list.compact-view .link-card-main {
  flex: 1;
  min-width: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

/* Hide favicon in compact mode */
.items-list.compact-view .link-card-favicon {
  display: none;
}

/* Title styling */
.items-list.compact-view .link-title {
  font-size: 0.875rem;
  font-weight: 500;
  -webkit-line-clamp: 2;
  line-height: 1.3;
}

/* Meta info */
.items-list.compact-view .link-meta {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  color: var(--text-secondary);
}

/* Hide notes and snippets in compact mode */
.items-list.compact-view .link-note,
.items-list.compact-view .link-snippet {
  display: none !important;
}

/* Tags */
.items-list.compact-view .link-tags {
  display: flex !important;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.items-list.compact-view .link-tags .tag-badge {
  font-size: 0.65rem;
  padding: 0.0625rem 0.375rem;
}

/* Show only 3 tags */
.items-list.compact-view .link-tags .tag-badge:nth-child(n+4) {
  display: none;
}

/* Actions - hidden by default, show on hover */
.items-list.compact-view .link-actions {
  display: none !important;
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  padding: 0.25rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10;
}

@media (hover: hover) {
  .items-list.compact-view .link-card:hover .link-actions {
    display: flex !important;
  }
}

/* Auto-source badge (RSS / YouTube feed indicator) */
.auto-source-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.3rem;
  margin-left: 0.4rem;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.12);
  color: #3B82F6;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  text-decoration: none;
}
a.auto-source-badge:hover {
  background: rgba(59, 130, 246, 0.22);
}

.auto-source-badge::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e2e;
  color: #e8e8e8;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  border: 1px solid #3a3a5c;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 20;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auto-source-badge:hover::after {
  opacity: 1;
}
