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

:root {
  --bg: #f8f9fa;
  --card: #ffffff;
  --text: #222222;
  --text-muted: #666666;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --border: #e5e7eb;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* Navbar */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--primary); text-decoration: none; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.95rem; }
.nav-links a:hover { color: var(--text); }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.9rem;
  border: none; cursor: pointer; text-decoration: none; font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-hover); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #15803d; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover  { opacity: 0.85; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { opacity: 0.85; }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover  { background: var(--bg); }
.btn-muted    { background: #9ca3af; color: #fff; }
.btn-info     { background: #0d9488; color: #fff; }
.btn-info:hover     { background: #0f766e; }

/* Forms */
.form-control {
  width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.9rem; background: var(--card); color: var(--text);
}
.form-control--sm { width: auto; }
label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
label .form-control { margin-top: 0.3rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--text); }

/* Badges */
.badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-platform { background: #dbeafe; color: #1e40af; }
.badge-tmdb     { background: #f3f4f6; color: #6b7280; }
.badge-score    { background: #fef9c3; color: #854d0e; }
.badge-status--active    { background: #dcfce7; color: #15803d; }
.badge-status--paused    { background: #fef3c7; color: #92400e; }
.badge-status--planned   { background: #e0e7ff; color: #3730a3; }
.badge-status--completed { background: #d1fae5; color: #065f46; }
.badge-status--dropped   { background: #fee2e2; color: #991b1b; }

/* Search */
.search-form { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.search-input { flex: 1; }
.results-count { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.search-results { display: flex; flex-direction: column; gap: 1rem; }
.result-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; display: flex; gap: 1rem;
}
.result-poster { width: 60px; height: 90px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.result-poster--empty { width: 60px; height: 90px; background: var(--border); border-radius: 4px; flex-shrink: 0; }
.result-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.2rem; }
.result-original { color: var(--text-muted); font-size: 0.85rem; }
.result-year { color: var(--text-muted); font-size: 0.82rem; margin: 0.2rem 0; }
.result-overview { font-size: 0.85rem; color: var(--text-muted); margin: 0.4rem 0 0.75rem; }

/* Series grid */
.series-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem; }
.series-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.series-poster { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }
.series-poster--empty {
  width: 100%; aspect-ratio: 2/3; background: var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.8rem;
}
.series-card-body { padding: 0.75rem; }
.series-title { font-weight: 600; font-size: 0.9rem; display: block; text-decoration: none; color: var(--text); margin-bottom: 0.5rem; }
.series-title:hover { color: var(--primary); }
.series-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; }
.progress-bar-wrap { height: 4px; background: var(--border); border-radius: 99px; margin: 0.5rem 0 0.3rem; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 99px; }
.progress-text { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.next-episode {
  font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.5rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* Detail page */
.detail-header { display: flex; gap: 1.5rem; margin-bottom: 2rem; align-items: flex-start; }
.detail-poster { width: 180px; flex-shrink: 0; border-radius: var(--radius); }
.detail-info h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.original-name { color: var(--text-muted); margin-bottom: 0.5rem; }
.overview { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.75rem; max-width: 600px; }
.detail-stats { display: flex; gap: 1.25rem; margin-bottom: 0.75rem; }
.detail-stat { display: flex; flex-direction: column; }
.detail-stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-stat-value { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }

/* Seasons & Episodes */
.seasons-section { display: flex; flex-direction: column; gap: 1rem; }
.season-block { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.season-title {
  padding: 0.75rem 1rem; font-weight: 600; cursor: pointer; user-select: none;
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.season-title::-webkit-details-marker { display: none; }
.season-title-text { display: flex; align-items: center; gap: 0.5rem; }
.season-ep-count { font-weight: 400; color: var(--text-muted); font-size: 0.85rem; }
.season-bulk-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.episodes-list { border-top: 1px solid var(--border); }
.episode-row {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.episode-row:last-child { border-bottom: none; }
.episode-row--watched { background: #f0fdf4; }
.episode-row--skipped { background: #fefce8; }
.ep-code { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); min-width: 60px; text-decoration: none; }
.ep-code:hover { color: var(--primary); text-decoration: underline; }
.ep-name { flex: 1; font-size: 0.9rem; }
.ep-runtime { font-size: 0.78rem; color: var(--text-muted); }
.ep-actions { display: flex; gap: 0.3rem; }
.btn-ep.active { font-weight: 700; }

/* Edit page */
.edit-grid { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.edit-poster { width: 180px; flex-shrink: 0; border-radius: var(--radius); }
.edit-forms { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1.25rem; }
.edit-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.edit-section h2 { font-size: 1rem; margin-bottom: 0.75rem; }
.edit-section h2 .badge { margin-left: 0.4rem; vertical-align: middle; }
.edit-section--danger { border-color: #fecaca; }
.danger-actions, .status-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.status-actions .btn:disabled { opacity: 0.35; }
.hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }

/* Platforms */
.platforms-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.platform-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.platform-edit-form { display: flex; align-items: center; gap: 0.5rem; flex: 1; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty-state p { margin-bottom: 1rem; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 360px; }
.login-brand { font-size: 1.4rem; font-weight: 700; color: var(--primary); margin-bottom: 1.5rem; text-align: center; }
.btn-block { width: 100%; margin-top: 1rem; }

/* Logout */
.btn-logout {
  background: none; border: none; cursor: pointer; font-size: 0.88rem;
  color: var(--text-muted); padding: 0; line-height: 1;
}
.btn-logout:hover { color: var(--danger); }

/* Trending */
.trending-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.trending-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.trending-poster-link { display: block; position: relative; }
.trending-poster { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; transition: opacity 0.15s; }
.trending-poster-link:hover .trending-poster { opacity: 0.85; }
.trending-poster--empty {
  width: 100%; aspect-ratio: 2/3; background: var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.8rem;
}
.trending-type-badge {
  position: absolute; top: 0.4rem; left: 0.4rem;
  background: rgba(0,0,0,0.65); color: #fff; font-size: 0.7rem; font-weight: 600;
  padding: 0.15rem 0.45rem; border-radius: 99px;
}
.trending-info { padding: 0.6rem 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; }
.trending-title {
  font-size: 0.85rem; font-weight: 600; color: var(--text); text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.trending-title:hover { color: var(--primary); }

/* Filter tabs */
.filter-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.filter-tab {
  padding: 0.4rem 1rem; border-radius: 99px; font-size: 0.88rem;
  text-decoration: none; color: var(--text-muted); border: 1px solid var(--border);
  background: var(--card);
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* List filters */
.list-filters {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem;
}
.platform-filter { display: flex; align-items: center; }

/* Archive list */
.archive-list { display: flex; flex-direction: column; gap: 0.75rem; }
.archive-row {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem 1rem; display: flex; align-items: center; gap: 1rem;
}
.archive-poster { width: 46px; height: 69px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.archive-poster--empty { width: 46px; height: 69px; background: var(--border); border-radius: 4px; flex-shrink: 0; }
.archive-info { flex: 1; min-width: 0; }
.archive-title { font-weight: 600; font-size: 0.95rem; text-decoration: none; color: var(--text); display: block; margin-bottom: 0.3rem; }
.archive-title:hover { color: var(--primary); }
.archive-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.3rem; align-items: center; }
.archive-actions { flex-shrink: 0; }
.text-muted { font-size: 0.82rem; color: var(--text-muted); }

/* Responsive */
@media (max-width: 600px) {
  .detail-header { flex-direction: column; }
  .detail-poster { width: 120px; }
  .series-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .edit-poster { width: 120px; }
}
