:root {
  color-scheme: dark;
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;

  --bg-primary: #0e1219;
  --bg-secondary: #141b26;
  --surface: #18212e;
  --surface-elevated: #1b2635;
  --surface-hover: #223246;
  --bg-nav: rgba(14, 18, 25, 0.96);
  --bg-overlay: rgba(6, 9, 13, 0.72);

  --text-primary: #f1f5f9;
  --text-secondary: #d2d8e1;
  --text-muted: #9aa7b4;

  --accent-primary: #f2b35d;
  --accent-secondary: #5bcf8e;
  --accent-tertiary: #6ec9f5;
  --accent-error: #ef4444;

  --primary: var(--accent-primary);
  --secondary: var(--accent-tertiary);
  --success: var(--accent-secondary);

  --border-color: rgba(148, 163, 184, 0.2);
  --border-hover: rgba(242, 179, 93, 0.5);

  --shadow-sm: 0 6px 18px rgba(6, 10, 18, 0.35);
  --shadow-md: 0 14px 30px rgba(6, 10, 18, 0.45);
  --shadow-lg: 0 24px 50px rgba(6, 10, 18, 0.55);

  --border-radius-sm: 10px;
  --border-radius-md: 14px;
  --border-radius-lg: 18px;

  --spacing-xs: 6px;
  --spacing-sm: 10px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  --font-size-sm: 0.85rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.2rem;

  --transition-fast: 0.2s ease;
  --transition-slow: 0.35s ease;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 0%, rgba(110, 201, 245, 0.08), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(242, 179, 93, 0.1), transparent 50%),
    linear-gradient(180deg, #0e1219 0%, #0d141f 60%, #0f1824 100%);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  touch-action: manipulation;
}

*,
*::before,
*::after {
  touch-action: manipulation;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

img {
  max-width: 100%;
  display: block;
}

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

.fade-in {
  animation: fadeIn 0.5s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content {
  position: relative;
  z-index: 1;
  padding: 28px 18px calc(110px + env(safe-area-inset-bottom));
  max-width: 1200px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}

.catalog-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  text-align: center;
}

.catalog-subtitle {
  margin: 0;
  color: var(--text-muted);
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(110deg, #f59e0b 0%, #38bdf8 60%, #22c55e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.nav {
  position: fixed !important;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 12px env(safe-area-inset-bottom);
  background: var(--bg-nav);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  z-index: 1000;
  transform: translateZ(0);
}

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.nav-link.active {
  color: var(--text-primary);
  background: rgba(245, 158, 11, 0.16);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.4);
}

.nav-link:hover {
  color: var(--text-primary);
  transform: translateY(-2px);
}

.nav-icon {
  width: 24px;
  height: 24px;
  filter: brightness(1.35) saturate(1.1);
  opacity: 0.9;
}

.nav-link.active .nav-icon {
  filter: brightness(1.6) saturate(1.2) drop-shadow(0 6px 10px rgba(245, 158, 11, 0.4));
  opacity: 1;
}

.search-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--border-radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.search-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-btn,
.filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.search-btn {
  background: linear-gradient(120deg, rgba(245, 158, 11, 0.2), rgba(56, 189, 248, 0.2));
  color: var(--text-primary);
}

.filter-btn {
  background: rgba(15, 23, 32, 0.6);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.filter-actions {
  display: flex;
  justify-content: center;
}

.search-container {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: center;
}

.search-form {
  display: flex;
  flex: 1;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
}

.search-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 240px;
  max-width: 320px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  padding: 10px 14px;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  min-width: 0;
}

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

.search-button,
.filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}

.search-button {
  background: linear-gradient(135deg, rgba(242, 179, 93, 0.25), rgba(110, 201, 245, 0.2));
  color: var(--text-primary);
  border: 1px solid rgba(242, 179, 93, 0.35);
}

.filter-button {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.25);
  flex: 0 0 auto;
}

.search-button:hover,
.filter-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(110, 201, 245, 0.5);
  box-shadow: var(--shadow-md);
}

.card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.card-content {
  padding: 14px 16px 18px;
}

.title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.info-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.count-number {
  font-weight: 700;
  color: var(--text-primary);
}

.count-label {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(120deg, rgba(245, 158, 11, 0.2), rgba(56, 189, 248, 0.2));
  color: var(--text-primary);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: rgba(15, 23, 32, 0.7);
  border-color: rgba(148, 163, 184, 0.2);
  color: var(--text-secondary);
}

.filter-results-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 18px 0 4px;
  color: var(--text-muted);
}

.sort-section {
  background: rgba(10, 16, 24, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  padding: 12px 14px;
}

.filter-section h4,
.sort-section h4 {
  margin: 0 0 10px 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.filter-text {
  font-weight: 600;
  color: var(--text-secondary);
}

.filter-details {
  color: var(--text-muted);
}

.count-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.results-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.original-count {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  z-index: 2000;
}

.modal-content {
  width: min(720px, 100%);
  background: var(--surface-elevated);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-top: calc(12px + env(safe-area-inset-top));
}

.modal-header,
.modal-footer {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0;
}

.modal-close {
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.modal-body {
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 70vh;
  overflow-y: auto;
}

.filter-columns {
  display: grid;
  gap: 16px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.8rem;
}

.checkbox-label input {
  accent-color: var(--accent-primary);
}

.year-filter {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.year-filter input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text-primary);
}

.sort-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text-primary);
}

.sort-select option {
  background: #101722;
  color: var(--text-primary);
}

.checkbox-grid::-webkit-scrollbar {
  width: 6px;
}

.checkbox-grid::-webkit-scrollbar-track {
  background: transparent;
}

.checkbox-grid::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}

.anime-detail {
  display: grid;
  gap: 24px;
  margin-top: 30px;
}

/* Back button container removed, now overlay */


.back-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, background 0.2s ease;
}

.back-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-2px);
}

.anime-poster {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  aspect-ratio: 2/3;
  background: var(--surface-elevated);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.anime-info {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.title-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.anime-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  margin: 0;
}

.favorite-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 16px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.1);
}

.favorite-btn:active {
  transform: scale(0.98);
}

.favorite-btn.favorited {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.6);
}

.anime-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meta-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: start;
}

.meta-label {
  color: var(--text-muted);
  font-weight: 600;
}

.meta-value {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.year-badge,
.genre-badge,
.theme-badge,
.episode-count-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 32, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.anime-description {
  background: rgba(10, 16, 24, 0.6);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 16px;
}

.description-text {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.description-text.is-expanded {
  display: block;
  -webkit-line-clamp: initial;
  -webkit-box-orient: initial;
  max-height: none;
}

.description-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toggle-description-btn {
  background: none;
  border: none;
  color: var(--accent-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.episodes-section {
  margin-top: 36px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 16px;
}

.season-card {
  background: var(--surface-elevated);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 16px;
  margin-bottom: 20px;
}

.season-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.episodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.episode-card {
  background: rgba(10, 16, 24, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.episode-number {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.watch-episode-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.2);
  color: var(--text-primary);
  cursor: pointer;
}

.watch-episode-btn.sent-to-bot {
  background: rgba(34, 197, 94, 0.2);
  color: var(--text-primary);
}

.user-message {
  margin-bottom: 10px;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
}

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

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(148, 163, 184, 0.2);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

.history-card,
.favorite-card {
  background: var(--surface-elevated);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.favorite-tile {
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: linear-gradient(180deg, rgba(15, 23, 32, 0.9), rgba(9, 13, 20, 0.95));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, border-color 0.25s ease;
  position: relative;
}

.favorite-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 0%, rgba(34, 197, 94, 0.18), transparent 50%),
    radial-gradient(circle at 20% 100%, rgba(56, 189, 248, 0.2), transparent 55%);
  pointer-events: none;
}

.favorite-tile:hover {
  transform: translateY(-6px);
  border-color: rgba(34, 197, 94, 0.55);
}

.favorite-tile-poster-wrap {
  height: 220px;
  overflow: hidden;
}

.favorite-tile-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.favorite-tile-content {
  position: relative;
  z-index: 1;
  padding: 14px 16px 18px;
}

.favorite-tile-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.35;
  color: var(--text-primary);
}

.favorite-tile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.favorite-tile-stats span {
  font-size: 0.78rem;
  color: rgba(226, 232, 240, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.5);
}

.favorite-card {
  display: flex;
  flex-direction: column;
}

.favorite-poster {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.favorite-content {
  padding: 14px 16px 18px;
}

.favorite-title {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0 0 8px 0;
}

.favorite-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.favorite-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.remove-favorite-btn,
.view-details-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 32, 0.6);
  color: var(--text-secondary);
  cursor: pointer;
}

.remove-favorite-btn {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

.history-card {
  display: flex;
  gap: 16px;
}

.history-poster-container {
  width: 120px;
  height: 160px;
  flex-shrink: 0;
}

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

.history-content {
  padding: 16px 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-anime-title {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-label {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-input--compact {
  flex: 0 0 160px;
  max-width: 180px;
  background: rgba(10, 16, 24, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 10px 12px;
}

.filter-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.results-info {
  margin: 18px 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.results-info h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 32, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}

.history-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  margin-top: 4px;
}

.history-tile {
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: 20px;
  padding: 18px;
  background: rgba(10, 16, 24, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.history-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.3), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.history-tile:hover {
  transform: translateY(-4px);
  border-color: rgba(56, 189, 248, 0.6);
}

.history-tile:hover::after {
  opacity: 1;
}

.history-poster-circle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(59, 130, 246, 0.65);
  box-shadow: 0 0 0 8px rgba(2, 6, 23, 0.7);
  flex-shrink: 0;
}

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

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-meta span {
  font-weight: 600;
  color: var(--text-primary);
}

.history-date {
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.9);
}

.load-more-container {
  display: flex;
  justify-content: center;
  margin: 22px 0 10px;
}

.pagination-container {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 32, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  flex-wrap: wrap;
  justify-content: center;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.pagination-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.pagination-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.current-page {
  font-weight: 700;
  color: var(--text-primary);
}

.genres-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 8px;
}

.genre-section {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.genre-section .section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.genre-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.genre-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(10, 16, 24, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.genre-carousel {
  position: relative;
}

.carousel-container {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.carousel-container::-webkit-scrollbar {
  display: none;
}

.carousel-container .card {
  flex: 0 0 180px;
}

.carousel-container .card img {
  height: 200px;
}

.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(9, 13, 18, 0.85);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}

.carousel-nav.prev {
  left: -6px;
}

.carousel-nav.next {
  right: -6px;
}

.episode-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.season-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.error-container {
  text-align: center;
  padding: 40px 20px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
}

.error-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-error);
}

.error-message {
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.top-list {
  display: grid;
  gap: 16px;
}

.top-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: var(--border-radius-lg);
  background: var(--surface-elevated);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.top-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: var(--shadow-md);
}

.top-rank {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.top-details {
  flex: 1;
  min-width: 0;
}

.top-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0 0 4px 0;
}

.top-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.top-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.top-meta span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(10, 16, 24, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.top-action {
  display: flex;
  align-items: center;
}

.top-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.4);
  font-size: 0.75rem;
  font-weight: 600;
}

@media (min-width: 900px) {
  .content {
    padding: 40px 32px 140px;
  }

  .anime-detail {
    grid-template-columns: 320px 1fr;
    align-items: start;
  }

  .search-container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .filter-columns {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .search-container,
  .search-form {
    flex-direction: row;
  }

  .search-wrapper {
    flex-direction: row;
    max-width: 260px;
  }

  .search-form {
    gap: 8px;
  }

  .filter-button {
    padding: 8px 10px;
    font-size: 0.75rem;
  }

  .history-card {
    flex-direction: column;
  }

  .history-poster-container {
    width: 100%;
    height: 180px;
  }

  .meta-row {
    grid-template-columns: 1fr;
  }

  .search-input--compact {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .pagination {
    flex-direction: row;
    gap: 10px;
    border-radius: var(--border-radius-lg);
  }

  .carousel-nav {
    display: none;
  }

  .carousel-container .card {
    flex: 0 0 150px;
  }

  .carousel-container .card img {
    height: 170px;
  }

  .top-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-rank {
    width: 44px;
    height: 44px;
  }
}