* { box-sizing: border-box; }

:root {
  --bg: #0b0b0d;
  --bg-alt: #17171b;
  --text: #f2f2f2;
  --text-dim: #a3a3a3;
  --accent: #e50914;
}

html {
  min-height: 100%;
  background-color: var(--bg);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  background-image: linear-gradient(rgba(11, 11, 13, 0.85), rgba(11, 11, 13, 0.85)), var(--bg-image, url("/api/background/me"));
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  background-repeat: no-repeat;
}

body.profiles-body {
  background-image: linear-gradient(rgba(11, 11, 13, 0.78), rgba(11, 11, 13, 0.78)), url("img/profiles-bg.jpg");
}

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

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 40px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
}

.logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.search-wrap {
  flex: 1;
  max-width: 420px;
}

.site-nav {
  display: flex;
  gap: 20px;
  font-size: 14px;
  white-space: nowrap;
}

.site-nav a {
  color: var(--text-dim);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
}

#search-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 4px;
  border: 1px solid #333;
  background: rgba(0,0,0,0.6);
  color: var(--text);
  font-size: 14px;
}

#search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.content {
  padding: 24px 40px 80px;
}

.row {
  margin-bottom: 36px;
}

.row-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 12px 2px;
}

.row-items {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.card {
  flex: 0 0 auto;
  width: 160px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.card:hover {
  transform: scale(1.08);
  z-index: 2;
}

.card-poster {
  width: 160px;
  height: 240px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-alt);
  display: block;
}

.card-title {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-msg {
  color: var(--text-dim);
  padding: 40px;
  text-align: center;
}

.state-msg {
  color: var(--text-dim);
  padding: 12px 2px;
}

/* Detail page */
.detail-hero {
  display: flex;
  gap: 32px;
  padding: 40px;
  flex-wrap: wrap;
}

.detail-poster {
  width: 260px;
  height: 390px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-alt);
}

.detail-info { flex: 1; min-width: 260px; }

.detail-info h1 { font-size: 32px; margin: 0 0 8px; }

.detail-meta { color: var(--text-dim); margin-bottom: 20px; }

.btn-play {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

.btn-play:hover { background: #ff2030; }

.btn-back {
  display: inline-block;
  margin: 20px 0 0 40px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}

.btn-back:hover { color: var(--text); }

.season-select-wrap {
  margin: 8px 40px 24px;
}

.season-select {
  padding: 10px 14px;
  border-radius: 4px;
  border: 1px solid #333;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 14px;
  min-width: 260px;
  cursor: pointer;
}

.season-select:focus {
  outline: none;
  border-color: var(--accent);
}

.season-block { margin: 0 40px 28px; }

.season-title { font-size: 18px; margin-bottom: 10px; }

.episode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-alt);
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
}

.episode-row:hover { background: #202027; }

.episode-num {
  color: var(--text-dim);
  font-size: 13px;
  margin-right: 12px;
}

/* Watch page */
.watch-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.watch-header {
  padding: 16px 24px;
  background: #000;
}

.watch-title {
  font-size: 16px;
  color: var(--text-dim);
  margin-left: 12px;
}

video {
  width: 100%;
  max-height: 85vh;
  background: black;
  flex: 1;
}

.player-wrap {
  position: relative;
  display: flex;
  flex: 1;
}

.skip-intro-btn {
  position: absolute;
  right: 32px;
  bottom: 90px;
  background: rgba(20, 20, 20, 0.85);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.6);
  font-size: 15px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
}

.skip-intro-btn:hover { background: rgba(255, 255, 255, 0.9); color: #000; }

.watch-actions {
  display: flex;
  justify-content: flex-end;
  padding: 12px 24px 20px;
  background: #000;
}

.hidden { display: none !important; }

/* Profile badge (header) */
.profile-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  white-space: nowrap;
}

.profile-badge {
  color: var(--text);
  font-weight: 600;
}

.profile-switch {
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
}

.profile-switch:hover { color: var(--text); }

/* Profile picker page */
.profiles-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
}

.profiles-logo { margin-bottom: 60px; }

.profiles-heading {
  font-size: 32px;
  margin-bottom: 40px;
}

.profiles-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: center;
  max-width: 900px;
}

.profile-tile {
  width: 140px;
  cursor: pointer;
  text-align: center;
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6a3093, #a044ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 700;
  color: white;
  margin-bottom: 10px;
  transition: outline 0.15s ease;
}

.profile-tile:hover .profile-avatar {
  outline: 3px solid var(--text);
}

.profile-avatar-add {
  background: var(--bg-alt);
  color: var(--text-dim);
  font-size: 48px;
}

.profile-name {
  font-size: 15px;
  color: var(--text-dim);
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 140px;
}

.inline-form input {
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #333;
  background: rgba(0,0,0,0.6);
  color: var(--text);
  font-size: 13px;
}

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

.inline-form button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.inline-form button:hover { background: #ff2030; }

.form-error {
  color: #ff6b6b;
  font-size: 12px;
}

/* Category grid (browse page) */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px 12px;
  padding: 0 2px;
}

.category-heading {
  font-size: 26px;
  margin: 0 0 24px;
}

/* Row title as a link */
.row-title-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.row-title-link:hover { text-decoration: underline; }

.row-title-arrow {
  font-size: 14px;
  color: var(--text-dim);
}

/* Continue-watching progress bar */
.card-progress-track {
  height: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  background: var(--accent);
}

.card-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Detail page actions */
.detail-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.25);
  cursor: pointer;
}

.btn-secondary:hover { background: rgba(255,255,255,0.16); }

.btn-secondary.active {
  background: rgba(255,255,255,0.2);
  border-color: var(--text);
}

.watched-badge {
  color: #4caf50;
  font-size: 13px;
  font-weight: 600;
}

.episode-progress-track {
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin-top: 6px;
  width: 100%;
}

.episode-progress-fill {
  height: 100%;
  background: var(--accent);
}

.episode-check {
  color: #4caf50;
  margin-right: 6px;
}

/* My List page */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tab-button {
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 4px;
  margin-right: 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.tab-button:hover { color: var(--text); }

.tab-button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.card-relative { position: relative; }

.card-link { display: block; }

.card-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.75);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-remove:hover { background: var(--accent); }

/* Settings page */
.settings-section {
  max-width: 520px;
}

.settings-heading {
  font-size: 20px;
  margin: 0 0 8px;
}

.settings-desc {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 20px;
}

.bg-preview-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-alt);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

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

.bg-upload-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bg-upload-form input[type="file"] {
  color: var(--text-dim);
  font-size: 13px;
}
