/*
 * Stowaway Design System
 * Design reference: design-system/stowaway/MASTER.md
 * Class names retained from legacy for JS compatibility; tokens follow MASTER.md naming.
 */

/* ============================================
   Design Tokens
   ============================================ */

:root {
  /* Colors - Light Mode (MASTER.md Section 1) */
  --color-bg: #F8F8F6;
  --color-surface: #FFFFFF;
  --color-surface-raised: #FFFFFF;
  --color-text: #1A1A1A;
  --color-text-secondary: #6B6B6B;
  --color-text-tertiary: #9CA3AF;
  --color-border: #E5E5E3;
  --color-border-strong: #D1D1CF;
  --color-accent: #2563EB;
  --color-accent-hover: #1D4ED8;
  --color-accent-subtle: #EFF6FF;
  --color-logo-inner: #FFFFFF;
  --color-logo-inner-shade: #EFF6FF;
  --color-highlight: #FEF3C7;
  --color-highlight-strong: #FDE68A;
  --color-success: #059669;
  --color-warning: #D97706;
  --color-danger: #DC2626;

  /* Typography Scale (MASTER.md Section 2) */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;

  /* Spacing (MASTER.md Section 3) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Shadows - Light Mode (MASTER.md Section 4) */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.1);

  /* Border Radius (MASTER.md Section 4) */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-width: 260px;
  --reading-pane-width: 500px;

  /* Reading pane text size multiplier */
  --reading-text-size: 1;

  color-scheme: light dark;
}

/* Dark Mode (MASTER.md Section 1) */
[data-theme="dark"] {
  --color-bg: #141414;
  --color-surface: #1C1C1C;
  --color-surface-raised: #242424;
  --color-text: #ECECEC;
  --color-text-secondary: #9CA3AF;
  --color-text-tertiary: #6B7280;
  --color-border: #2A2A2A;
  --color-border-strong: #3D3D3D;
  --color-accent: #60A5FA;
  --color-accent-hover: #93C5FD;
  --color-accent-subtle: rgba(37,99,235,0.12);
  --color-logo-inner: #1D4ED8;
  --color-logo-inner-shade: #2563EB;
  --color-highlight: rgba(251,191,36,0.18);
  --color-highlight-strong: rgba(251,191,36,0.3);
  --color-success: #34D399;
  --color-warning: #FBBF24;
  --color-danger: #F87171;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.5);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.6);
}

/* System color scheme preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #141414;
    --color-surface: #1C1C1C;
    --color-surface-raised: #242424;
    --color-text: #ECECEC;
    --color-text-secondary: #9CA3AF;
    --color-text-tertiary: #6B7280;
    --color-border: #2A2A2A;
    --color-border-strong: #3D3D3D;
    --color-accent: #60A5FA;
    --color-accent-hover: #93C5FD;
    --color-accent-subtle: rgba(37,99,235,0.12);
    --color-logo-inner: #1D4ED8;
    --color-logo-inner-shade: #2563EB;
    --color-highlight: rgba(251,191,36,0.18);
    --color-highlight-strong: rgba(251,191,36,0.3);
    --color-success: #34D399;
    --color-warning: #FBBF24;
    --color-danger: #F87171;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.5);
    --shadow-xl: 0 24px 48px rgba(0,0,0,0.6);
  }
}

/* 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;
  }
}

/* ============================================
   Reset & Global
   ============================================ */

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select {
  font-family: inherit;
  font-size: inherit;
}

.hidden {
  display: none !important;
}

/* ============================================
   Screens
   ============================================ */

.screen {
  min-height: 100vh;
}

/* ============================================
   Auth Screen
   ============================================ */

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
}

.auth-container {
  background: var(--color-surface);
  padding: var(--space-12);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 400px;
}

.logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.logo-icon {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.logo h1 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.logo p {
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#auth-form input {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

#auth-form input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.error {
  color: var(--color-danger);
  font-size: var(--text-sm);
  margin-top: var(--space-3);
  text-align: center;
}

.message {
  color: var(--color-success);
  font-size: var(--text-sm);
  margin-top: var(--space-3);
  text-align: center;
}

/* Splash, password reset, invite screens share auth layout */
#splash-screen,
#password-reset-screen,
#invite-accept-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
}

/* Reuse auth-form styles for reset and invite forms */
#password-reset-form,
#invite-accept-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#password-reset-form input,
#invite-accept-form input {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

#password-reset-form input:focus,
#invite-accept-form input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.forgot-password-link {
  display: block;
  text-align: center;
  margin-top: var(--space-3);
  color: var(--color-accent);
  font-size: var(--text-sm);
  text-decoration: none;
}

.forgot-password-link:hover {
  text-decoration: underline;
}

.invite-only-notice {
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: var(--text-xs);
  margin-top: var(--space-4);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-text);
  color: var(--color-surface);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms ease;
  z-index: 10000;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--color-accent);
  color: #FFFFFF;
}

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

.btn.secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
}

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

.btn.icon {
  padding: var(--space-2);
  background: transparent;
  color: var(--color-text-secondary);
}

.btn.icon:hover {
  background: var(--color-accent-subtle);
  color: var(--color-text);
}

.btn.danger {
  background: var(--color-danger);
  color: #FFFFFF;
}

.btn.danger:hover {
  background: color-mix(in srgb, var(--color-danger) 85%, black);
}

.btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

#favorite-btn.active svg {
  fill: currentColor;
}

#read-status-btn.active svg {
  fill: currentColor;
}

#read-toggle-btn.active svg {
  fill: currentColor;
}

/* ============================================
   Main Screen Layout
   ============================================ */

#main-screen {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.logo-small {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-header span {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Navigation */
.nav {
  padding: var(--space-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px var(--space-4);
  margin: 1px var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: background 150ms ease, color 150ms ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: var(--text-sm);
}

.nav-item:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  font-weight: 500;
}

.nav-section {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.nav-section h3 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-3);
}

.add-collection-btn {
  display: block;
  width: 100%;
  padding: var(--space-2);
  background: none;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
  margin-top: var(--space-2);
  transition: all 150ms ease;
}

.add-collection-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.collection-item {
  display: flex;
  align-items: center;
  position: relative;
}

.collection-item .collection-link {
  flex: 1;
  min-width: 0;
}

.collection-item .collection-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-count {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-left: auto;
  flex-shrink: 0;
}

.collection-overflow-btn {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
  padding: 2px 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 150ms ease, color 150ms ease;
  flex-shrink: 0;
}

.collection-item:hover .collection-overflow-btn {
  opacity: 1;
}

@media (pointer: coarse) {
  .collection-overflow-btn {
    opacity: 1;
  }
}

.collection-overflow-btn:hover {
  color: var(--color-text);
  background: var(--color-hover);
}

.collection-context-menu {
  position: absolute;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  min-width: 120px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.collection-context-menu.active {
  opacity: 1;
  transform: translateY(0);
}

.collection-context-item {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 150ms ease;
}

.collection-context-item:hover {
  background: var(--color-hover);
}

.collection-context-item.danger {
  color: var(--color-danger);
}

.collection-context-item.danger:hover {
  background: rgba(220, 38, 38, 0.1);
}

.collection-inline-input {
  display: block;
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  margin-top: var(--space-2);
}

.collection-inline-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.collection-assign-dropdown {
  position: absolute;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  min-width: 200px;
  max-width: 280px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.collection-assign-dropdown.active {
  opacity: 1;
  transform: translateY(0);
}

.collection-assign-list {
  max-height: 200px;
  overflow-y: auto;
}

.collection-assign-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 150ms ease;
}

.collection-assign-item:hover {
  background: var(--color-hover);
}

.collection-assign-item.assigned {
  font-weight: 500;
  color: var(--color-accent);
}

.collection-assign-item.remove {
  color: var(--color-text-tertiary);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-1);
  padding-top: var(--space-2);
}

.collection-assign-check {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.collection-assign-empty {
  padding: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  text-align: center;
}

.save-card-collection {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.save-card-collection svg {
  flex-shrink: 0;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  background: var(--color-accent-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-accent);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  border: none;
}

.tag:hover {
  background: var(--color-accent);
  color: #FFFFFF;
}

.tag.active {
  background: var(--color-accent);
  color: #FFFFFF;
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* Dark mode toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 150ms ease;
  width: 100%;
  margin-bottom: var(--space-2);
}

.theme-toggle:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

/* ============================================
   Main Content
   ============================================ */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.search-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  max-width: 500px;
  transition: border-color 150ms ease, background 150ms ease;
}

.search-container:focus-within {
  background: var(--color-surface);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.search-container svg {
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.search-container input {
  flex: 1;
  border: none;
  background: none;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.search-container input:focus {
  outline: none;
}

.search-container input::placeholder {
  color: var(--color-text-tertiary);
}

#mobile-menu-btn {
  display: none;
}

/* Content Area */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-6);
  min-width: 0;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.content-header h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.view-controls {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.view-controls select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.read-status-filters {
  display: flex;
  gap: var(--space-1);
  background: var(--color-bg);
  padding: var(--space-1);
  border-radius: var(--radius-md);
}

.read-filter-btn {
  padding: var(--space-1) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
}

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

.read-filter-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}

/* ============================================
   Saves Grid & Cards
   ============================================ */

.saves-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.save-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 200ms ease, border-color 200ms ease;
}

.save-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
}

.save-card.highlight {
  border-left: 4px solid var(--color-warning);
}

.save-card-image {
  width: 100%;
  height: 140px;
  background: var(--color-bg);
  object-fit: cover;
}

.save-card-content {
  padding: var(--space-4);
}

.save-card-site {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.save-card-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  line-height: 1.3;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.save-card-excerpt {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.save-card-highlight {
  font-size: var(--text-base);
  color: var(--color-text);
  font-style: italic;
  background: var(--color-highlight);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.save-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.save-card-date {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.save-card-read-time {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.save-card-tags {
  display: flex;
  gap: var(--space-1);
}

.save-card-tag {
  display: inline-block;
  padding: 2px var(--space-2);
  margin-left: var(--space-2);
  background: var(--color-accent-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-accent);
}

/* Read/Unread Status */
.save-card.unread .save-card-title {
  font-weight: 700;
}

.save-card.read {
  /* Opacity applied to individual elements instead of container */
}

/* Read article image grayscale */
.save-card.read .save-card-image {
  filter: grayscale(100%);
}

/* Read article text opacity - layered approach */
.save-card.read .save-card-title {
  opacity: 0.6;
  font-weight: 400;
}

.save-card.read .save-card-excerpt,
.save-card.read .save-card-site,
.save-card.read .save-card-meta {
  opacity: 0.5;
}

/* Read highlight cards */
.save-card.read .save-card-highlight {
  opacity: 0.6;
}

/* ============================================
   Loading & Empty States
   ============================================ */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
}

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

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-4);
}

.empty-state h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  max-width: 320px;
  line-height: 1.5;
}

/* ============================================
   Reading Pane
   ============================================ */

.reading-pane {
  width: var(--reading-pane-width);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.reading-actions {
  display: flex;
  gap: var(--space-1);
}

.reading-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.reading-meta {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-3);
}

.reading-meta-read-time {
  font-weight: 400;
}

#reading-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-6);
}

.reading-body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: calc(var(--text-lg) * var(--reading-text-size));
  line-height: 1.75;
  color: var(--color-text);
  overflow-wrap: break-word;
  word-break: break-word;
}

.reading-body p {
  margin-bottom: 1.25em;
}

.reading-body a {
  color: var(--color-accent);
  text-decoration: underline;
}

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

.reading-body strong {
  font-weight: 600;
}

.reading-body em {
  font-style: italic;
}

.reading-body code {
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.reading-body pre {
  background: var(--color-bg);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: var(--space-4) 0;
}

.reading-body pre code {
  background: none;
  padding: 0;
}

.reading-body blockquote {
  border-left: 2px solid var(--color-border-strong);
  padding-left: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.reading-body ul, .reading-body ol {
  margin: var(--space-4) 0;
  padding-left: var(--space-6);
}

.reading-body li {
  margin-bottom: var(--space-2);
}

.reading-body h1, .reading-body h2, .reading-body h3,
.reading-body h4, .reading-body h5, .reading-body h6 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  margin: 2em 0 0.75em;
  line-height: 1.3;
}

.reading-body h1 { font-size: var(--text-2xl); }
.reading-body h2 { font-size: var(--text-xl); }
.reading-body h3 { font-size: var(--text-lg); }

.reading-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
}

.text-size-controls {
  display: flex;
  gap: var(--space-1);
  margin-left: auto;
}

.text-size-controls .btn {
  padding: var(--space-1);
  min-width: 0;
  min-height: 0;
}

.reading-audio {
  margin: var(--space-4) 0;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-raised);
  border-radius: var(--radius-md);
}

.reading-audio audio {
  width: 100%;
  display: block;
}

.reading-tags {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.add-tag-btn {
  padding: 2px var(--space-3);
  background: none;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  transition: all 150ms ease;
}

.add-tag-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  border-style: solid;
}

.remove-tag-btn {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  margin-left: 4px;
  cursor: pointer;
  transition: color 150ms ease;
}

.remove-tag-btn:hover {
  color: var(--color-danger);
}

.tag-dropdown {
  position: absolute;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  min-width: 250px;
  max-width: 300px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.tag-dropdown.active {
  opacity: 1;
  transform: translateY(0);
}

.tag-dropdown input {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  background: var(--color-bg);
  color: var(--color-text);
}

.tag-dropdown input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.tag-dropdown-list {
  max-height: 200px;
  overflow-y: auto;
}

.tag-dropdown-item {
  padding: var(--space-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: background 150ms ease;
}

.tag-dropdown-item:hover {
  background: var(--color-hover);
}

.tag-dropdown-item.create-new {
  color: var(--color-accent);
  font-weight: 500;
}

.tag-dropdown-empty {
  padding: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  text-align: center;
}

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

.reading-progress-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-border);
  z-index: 10;
}

.reading-progress-fill {
  height: 100%;
  background: var(--color-accent);
  width: 0%;
  transition: width 100ms linear;
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 1024px) {
  .reading-pane {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 200;
    transition: left 0.3s;
    width: 85%;
    max-width: 320px;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
  }

  .sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
  }

  #mobile-menu-btn {
    display: flex;
  }

  .main-header {
    padding: var(--space-3) var(--space-4);
  }

  .search-container {
    padding: var(--space-2) var(--space-3);
  }

  .content {
    padding: var(--space-4);
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }

  .content-header h2 {
    font-size: var(--text-xl);
  }

  .saves-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .save-card-image {
    height: 120px;
  }

  .save-card-content {
    padding: var(--space-3);
  }

  .save-card-title {
    font-size: var(--text-base);
  }

  /* Full screen reading pane on mobile */
  .reading-pane {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .reading-pane.open {
    transform: translateX(0);
  }

  .reading-pane.hidden {
    display: flex !important;
    transform: translateX(100%);
  }

  .reading-header {
    padding: var(--space-3) var(--space-4);
    padding-top: calc(var(--space-3) + env(safe-area-inset-top));
  }

  .reading-content {
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  }

  #reading-title {
    font-size: 22px;
    margin-bottom: var(--space-4);
  }

  .reading-body {
    font-size: calc(17px * var(--reading-text-size));
    line-height: 1.7;
  }

  /* Larger touch targets */
  .btn.icon {
    padding: var(--space-3);
    min-width: 44px;
    min-height: 44px;
  }

  .nav-item {
    padding: 14px var(--space-3);
  }

  .nav-sub-item {
    padding: 10px var(--space-3);
  }

  /* Auth screen mobile */
  .auth-container {
    padding: var(--space-8) var(--space-6);
    margin: var(--space-4);
  }

  .logo-icon {
    width: 56px;
    height: 56px;
  }

  .logo h1 {
    font-size: var(--text-2xl);
  }
}

/* Extra small screens */
@media (max-width: 380px) {
  .content {
    padding: var(--space-3);
  }

  .save-card-content {
    padding: 10px;
  }

  .reading-content {
    padding: var(--space-3);
  }

  #reading-title {
    font-size: var(--text-xl);
  }
}

/* ============================================
   Stats Screen
   ============================================ */

.stats-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-6);
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.stat-card-value {
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--color-accent);
}

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.stats-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.stats-section h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-lg);
  margin-bottom: var(--space-4);
}

/* ============================================
   Modal
   ============================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.modal-header h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
}

/* ============================================
   Context Menu
   ============================================ */

.read-status-context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  min-width: 150px;
}

.read-status-context-menu-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: transparent;
  transition: background 0.15s ease;
}

.read-status-context-menu-item:hover {
  background: var(--color-accent-subtle);
}

.digest-description {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
  line-height: 1.5;
}

.digest-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.digest-form .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.digest-form label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.digest-form input[type="email"] {
  padding: 10px var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.digest-form input[type="email"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.digest-form select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.schedule-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.schedule-row span {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

.timezone-hint {
  font-size: var(--text-xs) !important;
  color: var(--color-text-tertiary) !important;
}

/* Toggle Switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-weight: normal !important;
}

.toggle-label input {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: 12px;
  transition: background 0.2s;
  flex-shrink: 0;
}

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

.toggle-label input:checked + .toggle-switch {
  background: var(--color-accent);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(20px);
}

.digest-status {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  text-align: center;
}

.digest-status.success {
  background: rgba(5, 150, 105, 0.1);
  color: var(--color-success);
}

.digest-status.error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-danger);
}

/* Nav sub-items (nested under parent nav items) */
.nav-sub-item {
  margin-left: 26px;
  font-size: var(--text-xs);
  opacity: 0.7;
}

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

.nav-sub-item:hover {
  opacity: 1;
}

.nav-sub-item.active {
  opacity: 1;
}

#digest-options,
#digest-schedule-group {
  transition: opacity 0.2s;
}

#digest-options.disabled,
#digest-schedule-group.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================
   Account View
   ============================================ */

.account-view {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.account-view-inner {
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.settings-section {
  padding: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.settings-section-heading {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 var(--space-4) 0;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.settings-description {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-4) 0;
  line-height: 1.5;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.settings-form .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.settings-form label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.settings-form input[type="password"] {
  padding: 10px var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.settings-form input[type="password"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.settings-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.settings-row-label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.settings-row-label span:first-child {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.settings-row-hint {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.settings-status {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.settings-status.success {
  background: rgba(5, 150, 105, 0.1);
  color: var(--color-success);
}

.settings-status.error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-danger);
}

/* Danger Zone */
.danger-zone {
  border-color: var(--color-danger);
}

.danger-zone .settings-section-heading {
  color: var(--color-danger);
  border-bottom-color: color-mix(in srgb, var(--color-danger) 30%, transparent);
}

.delete-account-confirmation {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.delete-account-warning {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-4) 0;
  line-height: 1.5;
}

/* ============================================
   Dropzone / Import
   ============================================ */

.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: all 150ms ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.dropzone.dragover {
  border-style: solid;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.dropzone-content svg {
  color: var(--color-text-tertiary);
}

.dropzone-content p {
  color: var(--color-text);
  font-size: var(--text-base);
}

.dropzone-hint {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.import-help {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  text-align: center;
}

.import-help code {
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: var(--text-xs);
}

/* Import Preview */
.import-preview {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.import-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  margin-bottom: var(--space-6);
}

.import-stat {
  text-align: center;
}

.import-stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--color-accent);
}

.import-stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.import-books-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.import-book-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

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

.import-book-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.import-book-author {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.import-book-count {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  background: var(--color-bg);
  padding: var(--space-1) 10px;
  border-radius: var(--radius-full);
}

/* Import success state */
.dropzone.success {
  border-color: var(--color-success);
  background: rgba(5, 150, 105, 0.05);
}

.dropzone.success svg {
  color: var(--color-success);
}

/* Processing state */
.dropzone.processing {
  pointer-events: none;
  opacity: 0.7;
}

/* ============================================
   Kindle View
   ============================================ */

.kindle-stats {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-bottom: var(--space-6);
  padding: var(--space-5);
  background: linear-gradient(135deg, var(--color-highlight) 0%, var(--color-highlight-strong) 100%);
  border-radius: var(--radius-lg);
}

.kindle-clear-btn {
  margin-left: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-warning);
  color: #92400e;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-4);
}

.kindle-clear-btn:hover {
  background: var(--color-highlight);
}

.kindle-stat {
  text-align: center;
}

.kindle-stat-value {
  display: block;
  font-size: var(--text-3xl);
  font-weight: 700;
  color: #92400e;
}

.kindle-stat-label {
  font-size: var(--text-sm);
  color: #a16207;
}

.kindle-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--space-4);
}

.kindle-book-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: box-shadow 200ms ease, border-color 200ms ease;
}

.kindle-book-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
}

.kindle-book-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.kindle-book-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.kindle-book-icon-large {
  font-size: 48px;
  flex-shrink: 0;
}

.kindle-book-info {
  flex: 1;
  min-width: 0;
}

.kindle-book-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kindle-book-author {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: 0;
}

.kindle-book-count {
  background: var(--color-bg);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.kindle-highlights-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kindle-highlight-snippet {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-style: italic;
  padding: 10px var(--space-3);
  background: var(--color-highlight);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-warning);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: background 150ms ease;
}

.kindle-highlight-snippet:hover {
  background: var(--color-highlight-strong);
}

.kindle-more-highlights {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  text-align: center;
  padding: var(--space-2);
}

/* Book Detail View */
.kindle-book-detail {
  max-width: 800px;
}

.kindle-back-btn {
  margin-bottom: var(--space-6);
}

.kindle-book-detail-header {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.kindle-book-detail-header h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-2xl);
  font-weight: 600;
  margin: 0 0 var(--space-1);
}

.kindle-book-meta {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-top: var(--space-2);
}

.kindle-highlights-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.kindle-highlight-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  cursor: pointer;
  transition: box-shadow 200ms ease, background 150ms ease;
}

.kindle-highlight-card:hover {
  box-shadow: var(--shadow-sm);
  background: var(--color-highlight);
}

.kindle-highlight-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
  font-style: italic;
}

.kindle-highlight-meta {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

@media (max-width: 768px) {
  .kindle-stats {
    gap: var(--space-6);
    padding: var(--space-4);
  }

  .kindle-stat-value {
    font-size: var(--text-2xl);
  }

  .kindle-books-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .kindle-book-card {
    padding: var(--space-4);
  }

  .kindle-book-icon {
    font-size: 24px;
  }

  .kindle-book-title {
    font-size: var(--text-base);
  }

  .kindle-book-detail-header {
    gap: var(--space-3);
  }

  .kindle-book-icon-large {
    font-size: 36px;
  }

  .kindle-book-detail-header h2 {
    font-size: var(--text-xl);
  }

  .kindle-highlight-card {
    padding: var(--space-4);
  }
}

@media (max-width: 768px) {
  .modal {
    padding: var(--space-4);
  }

  .modal-content {
    max-height: 85vh;
  }

  .modal-header {
    padding: var(--space-4);
  }

  .modal-body {
    padding: var(--space-4);
  }

  .dropzone {
    padding: var(--space-8) var(--space-4);
  }

  .import-stats {
    gap: var(--space-4);
  }

  .import-stat-value {
    font-size: var(--text-2xl);
  }
}

/* ============================================
   Queue View
   ============================================ */

.saves-grid.queue-active {
  display: block;
}

.queue-view {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
  overflow-wrap: break-word;
  word-break: break-word;
}

.queue-progress {
  text-align: center;
  margin-bottom: var(--space-6);
}

.queue-progress-text {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.queue-progress-bar {
  height: 3px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.queue-progress-fill {
  height: 100%;
  background: var(--color-accent);
  transition: width 300ms ease;
  border-radius: var(--radius-full);
}

.queue-content {
  flex: 1;
  padding-bottom: var(--space-8);
  min-width: 0;
}

.queue-meta {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-3);
}

.queue-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-6);
  overflow-wrap: break-word;
  word-break: break-word;
}

.queue-body {
  font-size: var(--text-lg);
  line-height: 1.75;
}

.queue-original-link {
  display: inline-block;
  margin-top: var(--space-4);
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 500;
}

.queue-original-link:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.queue-view-original {
  color: var(--color-accent);
  font-size: var(--text-lg);
  font-weight: 500;
}

.queue-view-original:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.queue-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  padding: var(--space-4) 0;
  position: sticky;
  bottom: 0;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

.queue-actions .btn {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  min-width: 120px;
}

.queue-skipped-notice {
  text-align: center;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--color-highlight);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

@media (max-width: 768px) {
  .queue-view {
    min-height: calc(100vh - 160px);
  }

  .queue-title {
    font-size: 22px;
    margin-bottom: var(--space-4);
  }

  .queue-body {
    font-size: 17px;
    line-height: 1.7;
  }

  .queue-actions {
    padding: var(--space-3) 0;
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
    gap: var(--space-2);
  }

  .queue-actions .btn {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    min-width: 0;
    flex: 1;
  }
}

/* ============================================
   Credits
   ============================================ */

.credits {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  text-align: center;
  line-height: 1.5;
}

.credits a {
  color: var(--color-text-secondary);
  text-decoration: underline;
}

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

/* ============================================
   Weekly Digest
   ============================================ */

.digest-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-1) 10px;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
  color: #FFFFFF;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
}

.digest-settings {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.digest-settings label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background 150ms ease;
}

.digest-settings label:hover {
  background: var(--color-surface);
}

.digest-settings input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
}

.digest-email-input {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-top: var(--space-3);
}

.digest-email-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

/* ============================================
   Weekly Review
   ============================================ */

.weekly-review {
  max-width: 900px;
}

.weekly-header {
  margin-bottom: var(--space-8);
}

.weekly-header h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: var(--space-1);
}

.weekly-dates {
  color: var(--color-text-tertiary);
  font-size: var(--text-base);
}

.weekly-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.weekly-stat {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
  color: #FFFFFF;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  text-align: center;
}

.weekly-stat-value {
  display: block;
  font-size: var(--text-4xl);
  font-weight: 700;
  line-height: 1;
  margin-bottom: var(--space-1);
}

.weekly-stat-label {
  font-size: var(--text-sm);
  opacity: 0.9;
}

.weekly-section {
  margin-bottom: var(--space-6);
}

.weekly-section h4 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

.weekly-sources {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.weekly-source {
  padding: 6px var(--space-3);
  background: var(--color-bg);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.weekly-rediscovery-hint {
  color: var(--color-text-tertiary);
  font-style: italic;
}

.rediscovery-card {
  background: linear-gradient(135deg, var(--color-highlight) 0%, var(--color-highlight-strong) 100%);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: box-shadow 200ms ease;
}

.rediscovery-card:hover {
  box-shadow: var(--shadow-lg);
}

.rediscovery-meta {
  font-size: var(--text-xs);
  color: #92400e;
  margin-bottom: var(--space-2);
}

.rediscovery-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--text-lg);
  font-weight: 600;
  color: #78350f;
  margin-bottom: var(--space-2);
}

.rediscovery-highlight {
  font-style: italic;
  color: #92400e;
  margin-bottom: var(--space-2);
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
}

.rediscovery-source {
  font-size: var(--text-sm);
  color: #a16207;
}

@media (max-width: 768px) {
  .weekly-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .weekly-stat {
    padding: var(--space-4);
  }

  .weekly-stat-value {
    font-size: 28px;
  }

  .weekly-header h3 {
    font-size: var(--text-2xl);
  }
}

/* ============================================
   Quick Save
   ============================================ */

#quick-save-btn {
  color: var(--color-accent);
  flex-shrink: 0;
}

#quick-save-btn:hover {
  background: var(--color-accent-subtle);
  color: var(--color-accent-hover);
}

.quick-save-modal-content {
  max-width: 420px;
}

#quick-save-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#quick-save-url {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

#quick-save-url:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.quick-save-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.quick-save-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.quick-save-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.quick-save-tags .tag.selected {
  background: var(--color-accent);
  color: #FFFFFF;
}

#quick-save-collection {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

#quick-save-collection:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.quick-save-status {
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  text-align: center;
}

.quick-save-status.success {
  background: rgba(5, 150, 105, 0.1);
  color: var(--color-success);
}

.quick-save-status.error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-danger);
}

/* ============================================
   Smart Clean-Up Modal
   ============================================ */

.cleanup-modal-content {
  max-width: 520px;
}

.cleanup-description {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

.cleanup-select-all {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-1);
}

.cleanup-select-all label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.cleanup-select-all input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
}

.cleanup-list {
  max-height: 360px;
  overflow-y: auto;
}

.cleanup-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 150ms ease;
}

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

.cleanup-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
  flex-shrink: 0;
  cursor: pointer;
}

.cleanup-item-info {
  flex: 1;
  min-width: 0;
}

.cleanup-item-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cleanup-item-meta {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  display: flex;
  gap: var(--space-2);
}

.cleanup-truncation {
  padding: var(--space-3);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  font-style: italic;
}

/* ============================================
   Book List View
   ============================================ */

.book-list-view {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.book-list-view__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.book-status-tabs {
  display: flex;
  gap: var(--space-1);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: var(--space-1);
}

.book-status-tabs__btn {
  padding: var(--space-1) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
}

.book-status-tabs__btn:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.book-status-tabs__btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}

.book-status-tabs__count {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-left: var(--space-1);
}

.book-list-view__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

.book-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 150ms ease;
}

.book-card:hover {
  box-shadow: var(--shadow-md);
}

.book-card__cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-card__cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-card__cover-placeholder {
  width: 100%;
  height: 100%;
  background: var(--color-accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--color-accent);
}

.book-card__info {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
}

.book-card__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card__author {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.book-card__actions {
  padding: var(--space-2) var(--space-3) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: space-between;
}

.book-status-btn {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  flex: 1;
}

.book-delete-btn {
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.book-delete-btn:hover {
  color: var(--color-danger);
}

/* Books empty state */
.books-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16);
  text-align: center;
  color: var(--color-text-secondary);
}

.books-empty-state__icon svg {
  stroke: var(--color-text-tertiary);
}

.books-empty-state h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.books-empty-state p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: 0;
  max-width: 300px;
}

/* Add Book modal */
.add-book-modal-content {
  width: 440px;
  max-width: calc(100vw - var(--space-8));
}

.add-book-modal-content .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.add-book-modal-content .form-group:last-child {
  margin-bottom: 0;
}

.add-book-modal-content label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.add-book-modal-content input,
.add-book-modal-content select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  box-sizing: border-box;
}

.add-book-modal-content input:focus,
.add-book-modal-content select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.required-mark {
  color: var(--color-danger);
}

.optional-mark {
  font-weight: 400;
  color: var(--color-text-tertiary);
  font-size: var(--text-xs);
}

/* ============================================
   Smart Sort Badge
   ============================================ */

.smart-sort-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: default;
  white-space: nowrap;
}

/* ============================================
   About Me Section
   ============================================ */

.about-me-char-count {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

#about-me-input {
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  resize: vertical;
  font-family: inherit;
}

#about-me-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}
