/* ── Shelf PWA — Editorial Curator Aesthetic ── */

:root {
  --bg: #f6f3ee;
  --bg-card: #fff;
  --bg-elevated: #ede9e1;
  --text: #1a1814;
  --text-secondary: #6b6560;
  --text-tertiary: #9e9790;
  --accent: #c45d3e;
  --accent-soft: #f0d8cf;
  --border: #e2ded6;
  --shadow: 0 1px 3px rgba(26, 24, 20, 0.06), 0 6px 16px rgba(26, 24, 20, 0.04);
  --shadow-lg: 0 4px 12px rgba(26, 24, 20, 0.08), 0 16px 40px rgba(26, 24, 20, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Instrument Sans', -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1814;
    --bg-card: #252220;
    --bg-elevated: #2e2a27;
    --text: #f0ece4;
    --text-secondary: #a09a92;
    --text-tertiary: #6b6560;
    --accent: #e07a5f;
    --accent-soft: #3d2a22;
    --border: #36322e;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 6px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.25), 0 16px 40px rgba(0, 0, 0, 0.2);
  }
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ── Screen transitions ── */

.screen {
  animation: screenIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  padding: 0 20px 32px;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Header / nav bar ── */

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -20px;
  right: -20px;
  height: 1px;
  background: var(--border);
}

.header-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.back-btn:active {
  transform: scale(0.92);
  background: var(--bg-elevated);
}

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

/* ── Home screen ── */

.home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-top: 20px;
}

.home-header .home-brand {
  padding: 8px 0;
  text-align: left;
}

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

.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-top: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

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

.refresh-btn:active {
  transform: scale(0.9);
  background: var(--bg-elevated);
}

.refresh-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

.home-brand {
  padding: 28px 0 8px;
  text-align: center;
}

.home-brand h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: -0.02em;
}

.home-brand p {
  color: var(--text-tertiary);
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ── Pending banner ── */

.pending-banner {
  padding: 14px 16px;
  margin: 20px 0;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  border-opacity: 0.2;
  animation: pulse-border 2s ease-in-out infinite;
  cursor: pointer;
}

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

.pending-chevron {
  margin-left: auto;
  color: var(--text-tertiary);
  transition: transform 0.2s;
}

.pending-chevron svg {
  width: 16px;
  height: 16px;
}

.pending-list {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}

.pending-list.expanded {
  display: flex;
}

.pending-item {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pending-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.pending-step {
  color: var(--accent);
  font-weight: 500;
  flex-shrink: 0;
  font-size: 0.72rem;
}

@keyframes pulse-border {
  0%, 100% { border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
  50% { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
}

.pending-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.pending-text {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--accent);
}

/* ── Category grid ── */

.section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin: 28px 0 14px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.category-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-lg);
}

.category-card:active::before {
  opacity: 1;
}

.category-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
  display: block;
  color: var(--accent);
}

.category-icon svg {
  width: 100%;
  height: 100%;
}

.category-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.25;
  margin-bottom: 4px;
}

.category-count {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ── Add link button ── */

.add-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-top: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.add-link-btn svg {
  width: 20px;
  height: 20px;
}

.add-link-btn:active {
  transform: scale(0.9);
  opacity: 0.85;
}

.add-link-textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.add-link-textarea:focus {
  border-color: var(--accent);
}

.add-link-textarea::placeholder {
  color: var(--text-tertiary);
}

/* ── Category search ── */

.category-search-wrap {
  position: relative;
  margin-top: 16px;
}

.category-search {
  width: 100%;
  padding: 11px 40px 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

.category-search:focus {
  border-color: var(--accent);
}

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

.category-search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s;
}

.category-search-clear svg {
  width: 16px;
  height: 16px;
}

.category-search-clear:active {
  color: var(--text);
}

/* ── Genre filter ── */

.genre-filter-wrap {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.genre-filter-wrap::-webkit-scrollbar {
  display: none;
}

.genre-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.genre-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── People (cast / directors) ── */

.people-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.people-row::-webkit-scrollbar {
  display: none;
}

.person-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  width: 80px;
  text-align: center;
}

.person-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-elevated);
}

.person-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--text-tertiary);
}

.person-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.person-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.person-role {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Links list ── */

.poster-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.skeleton-poster {
  aspect-ratio: 2/3;
  border-radius: var(--radius);
}

.poster-card {
  cursor: pointer;
  cursor: pointer;
  transition: transform 0.15s;
}

.poster-card:active {
  transform: scale(0.96);
}

.poster-frame {
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
  position: relative;
}

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

.poster-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

.poster-fallback svg {
  width: 32px;
  height: 32px;
}

.poster-watch-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2;
  padding: 0;
}

.poster-watch-btn svg {
  width: 18px;
  height: 18px;
}

.poster-watch-btn.watched {
  background: var(--accent);
  color: #fff;
}

.poster-watch-btn.updating {
  opacity: 0.5;
  pointer-events: none;
}

.poster-rating {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.7);
  color: #f5c518;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2;
  letter-spacing: 0.02em;
}

.poster-card.is-watched .poster-frame {
  opacity: 0.5;
}

.poster-card.is-watched .poster-title {
  color: var(--text-tertiary);
}

.poster-title {
  margin-top: 8px;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
}

/* ── Link detail ── */

.detail-hero {
  width: calc(100% + 40px);
  margin: 0 -20px;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--bg-elevated);
}

.detail-poster {
  width: 160px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin: 20px auto;
  display: block;
}

.detail-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 20px 0 8px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-tag {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 10px;
  background: var(--bg-elevated);
  border-radius: 6px;
  color: var(--text-secondary);
}

.detail-tag.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.detail-summary {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.detail-section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 24px 0 12px;
}

.detail-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

.detail-rating-value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--accent);
}

.detail-rating-label {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ── Recipe specifics ── */

.recipe-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0 24px;
}

.recipe-stat {
  text-align: center;
  padding: 14px 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.recipe-stat-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  display: block;
}

.recipe-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-top: 2px;
}

.ingredient-list {
  list-style: none;
  margin-bottom: 24px;
}

.ingredient-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ingredient-list li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.step-list {
  list-style: none;
  counter-reset: steps;
}

.step-list li {
  counter-increment: steps;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.55;
  display: flex;
  gap: 14px;
}

.step-list li::before {
  content: counter(steps);
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--accent);
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

/* ── Watch toggle ── */

.watch-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  margin: 16px 0;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.watch-toggle .watch-icon {
  display: flex;
  align-items: center;
}

.watch-toggle .watch-icon svg {
  width: 20px;
  height: 20px;
}

.watch-toggle.watched {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.watch-toggle:active {
  transform: scale(0.97);
}

/* ── Action buttons ── */

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 32px;
  padding-bottom: 20px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

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

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

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

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

.btn-danger:active {
  background: #c0392b;
  color: #fff;
  border-color: #c0392b;
}

/* ── Recategorize sheet ── */

.recat-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.recat-hint-input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

.recat-hint-input::placeholder {
  color: var(--text-tertiary);
}

.recat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.recat-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--accent);
}

.recat-btn:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.recat-btn:active svg {
  color: #fff;
}

.recat-retry {
  width: 100%;
  margin-top: 8px;
  justify-content: center;
  border-style: dashed;
}

.btn svg {
  width: 18px;
  height: 18px;
}

/* ── Empty state ── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.empty-state-text {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 20px;
  right: 20px;
  padding: 14px 18px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
  transform: translateY(120%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s, visibility 0.3s;
  z-index: 100;
  pointer-events: none;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

/* ── Watch providers ── */

.providers-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.provider-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.provider-chip:active {
  background: var(--border);
}

.provider-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.provider-logo-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.provider-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
}

.provider-count {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 10px;
}

.provider-countries {
  display: none;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 12px 12px;
  background: var(--card);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  margin-top: -2px;
}

.provider-countries.expanded {
  display: flex;
}

.country-flag {
  font-size: 1.4rem;
  cursor: pointer;
  position: relative;
  line-height: 1;
  padding: 2px;
}

.country-tooltip {
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
  animation: tooltipIn 0.15s ease-out;
}

@keyframes tooltipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Confirm overlay ── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.2s ease;
  padding: 0 12px calc(12px + var(--safe-bottom));
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.confirm-sheet {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 400px;
  animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.confirm-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.confirm-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions .btn {
  flex: 1;
  padding: 13px 16px;
}

/* ── Loading skeleton ── */

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-card {
  height: 110px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.skeleton-link {
  height: 88px;
  border: 1px solid var(--border);
}

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

/* ── Update banner ── */

.update-banner {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 20px;
  right: 20px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 200;
  animation: slideDown 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.update-banner button {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.update-banner button:active {
  background: rgba(255, 255, 255, 0.35);
}

@keyframes slideDown {
  from { transform: translateY(-120%); }
  to { transform: translateY(0); }
}

/* ── Book detail ── */

.book-author {
  color: var(--text-secondary);
  font-size: 1rem;
  margin: -4px 0 12px;
}

.book-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

/* ── Director filmography ── */

.director-filmography {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0;
}

.film-card {
  cursor: default;
}

.film-poster {
  position: relative;
  aspect-ratio: 2/3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
}

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

.film-poster .poster-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

.film-poster .poster-fallback svg {
  width: 24px;
  height: 24px;
}

.film-title {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 6px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.film-meta {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ── Cart FAB ── */

/* ── Staggered entry ── */

.stagger > * {
  animation: staggerIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stagger > *:nth-child(1) { animation-delay: 0.03s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.09s; }
.stagger > *:nth-child(4) { animation-delay: 0.12s; }
.stagger > *:nth-child(5) { animation-delay: 0.15s; }
.stagger > *:nth-child(6) { animation-delay: 0.18s; }
.stagger > *:nth-child(7) { animation-delay: 0.21s; }
.stagger > *:nth-child(8) { animation-delay: 0.24s; }
.stagger > *:nth-child(9) { animation-delay: 0.27s; }
.stagger > *:nth-child(10) { animation-delay: 0.30s; }

@keyframes staggerIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── History home link ── */

.history-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin: 24px 0 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.history-link:active {
  transform: scale(0.98);
  background: var(--bg-elevated);
}

.history-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.history-link-icon svg {
  width: 22px;
  height: 22px;
}

.history-link-text {
  flex: 1;
  min-width: 0;
}

.history-link-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.history-link-subtitle {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.history-link-chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.history-link-chevron svg {
  width: 18px;
  height: 18px;
}

/* ── History feed ── */

.history-list {
  padding-bottom: 20px;
}

.history-feed {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.history-item:active {
  transform: scale(0.98);
  background: var(--bg-elevated);
}

.history-thumb-wrap {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-elevated);
  position: relative;
}

.history-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-tertiary);
}

.history-thumb-fallback svg {
  width: 24px;
  height: 24px;
}

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

.history-title {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-url {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.history-status {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 4px;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.history-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 5px;
}

.history-cat-icon {
  display: inline-flex;
  align-items: center;
}

.history-cat-icon svg {
  width: 12px;
  height: 12px;
}

.history-domain {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.history-time {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 3px;
}

/* ── Language selector (settings) ── */

.settings-lang-section {
  margin-bottom: 4px;
}

.settings-lang-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.settings-lang-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--bg);
  border-radius: 12px;
  padding: 6px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lang-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-body);
  text-align: center;
}

.lang-pill-code {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
}

.lang-pill-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.lang-pill.active {
  background: var(--bg-elevated);
}

.lang-pill.active .lang-pill-code,
.lang-pill.active .lang-pill-name {
  color: var(--text);
}

.lang-pill:active:not(.active) {
  background: var(--bg-elevated);
  opacity: 0.7;
}

/* RTL support */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .home-header,
[dir="rtl"] .screen-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .back-btn svg {
  transform: scaleX(-1);
}

[dir="rtl"] .category-grid {
  direction: rtl;
}

[dir="rtl"] .link-row {
  flex-direction: row-reverse;
}

[dir="rtl"] .link-row .chevron-icon {
  transform: scaleX(-1);
}

/* ── Pull-to-refresh ── */

.ptr-indicator {
  position: fixed;
  top: calc(var(--safe-top) - 4px);
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s;
  opacity: 0;
  pointer-events: none;
}

.ptr-indicator.visible {
  opacity: 1;
}

.ptr-indicator svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
  transition: transform 0.2s ease;
}

.ptr-indicator.ready svg {
  transform: rotate(180deg);
}

.ptr-indicator.refreshing svg {
  animation: spin 0.8s linear infinite;
}

/* ── Shared category badge ── */

.category-shared-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-tertiary);
}

.category-shared-badge svg {
  width: 14px;
  height: 14px;
}

/* ── Share modal ── */

.share-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.share-email-input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

.share-email-input:focus {
  border-color: var(--accent);
}

.share-email-input::placeholder {
  color: var(--text-tertiary);
}

.share-invite-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.share-invite-btn:active {
  transform: scale(0.95);
  opacity: 0.85;
}

.share-invite-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.share-members-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.share-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.share-member-email {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-member-owner {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  flex-shrink: 0;
}

.share-member-remove {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.share-member-remove:active {
  background: #c0392b;
  color: #fff;
  border-color: #c0392b;
}

.share-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

/* ── Category detail share button ── */

.category-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  margin-left: auto;
}

.category-share-btn:active {
  transform: scale(0.92);
  background: var(--bg-elevated);
}

.category-share-btn svg {
  width: 18px;
  height: 18px;
}
