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

:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-input: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --success: #3fb950;
  --warn: #d29922;
  --error: #f85149;
}

html {
  overflow-y: scroll;
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- Header --- */

header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* --- Search --- */

.search-bar {
  margin-bottom: 1.5rem;
  transition: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-lang {
  flex-shrink: 0;
  padding: 0;
}

.search-bar input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

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

.search-bar.searching {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 4rem);
  max-width: 1200px;
  z-index: 300;
  margin: 0;
}

.search-results {
  margin-bottom: 2.5rem;
}

.search-results.searching {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 4rem);
  max-width: 1200px;
  max-height: calc(100vh - 88px);
  z-index: 300;
  overflow-y: auto;
  padding: 0;
  margin: 0;
}

.header-title {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--text);
}

.header-title h1 {
  font-size: 1.4rem;
  font-weight: 600;
}

.header-title:hover h1 {
  color: var(--accent);
}

/* --- Main --- */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* --- Search Overlay --- */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

/* --- Poster Grid --- */

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.movie-card {
  position: relative;
  color: var(--text);
  border-radius: 8px;
  overflow: visible;
  background: var(--bg-card);
  transition: transform 0.2s, box-shadow 0.2s;
}

.movie-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.movie-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  border-radius: 8px;
  overflow: hidden;
}

.add-btn {
  position: absolute;
  bottom: 44px;
  right: 6px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
  transition: background 0.2s;
}

.add-btn:hover:not([disabled]) {
  background: var(--accent-hover);
}

.add-btn[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
}

.already-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 0.5rem;
}

.already-in-list:hover .already-overlay {
  display: flex;
}

.movie-card:hover .add-btn {
  display: flex;
}


.poster-wrapper {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--bg-input);
}

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

.no-poster {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.no-poster.large {
  min-height: 400px;
  font-size: 1.1rem;
}

.movie-info {
  padding: 0.6rem 0.75rem;
}

.movie-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movie-year {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(248, 81, 73, 0.85);
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.movie-card:hover .remove-btn {
  display: flex;
}

/* --- Wishlists --- */

.wishlists-section {
  margin-top: 1rem;
}

.wishlists-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.wishlists-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.wishlists-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- View Toggle --- */

.view-toggle {
  display: flex;
  gap: 2px;
}

.btn-icon {
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  line-height: 1;
}

.btn-icon.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* --- Wishlist Carousel --- */

.carousel-wrapper {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.carousel-arrow {
  flex-shrink: 0;
  width: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.carousel-arrow:hover {
  background: var(--border);
}

.wishlist-tabs {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
  padding: 8px;
  margin: -8px;
}

.wishlist-tabs::-webkit-scrollbar {
  display: none;
}

.carousel-add-btn {
  flex-shrink: 0;
  width: 60px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.carousel-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

.carousel-side-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.carousel-side-buttons .carousel-add-btn,
.carousel-side-buttons .carousel-shared-btn {
  flex: 1;
  width: 60px;
  min-height: 0;
}

.carousel-shared-btn {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.carousel-shared-btn:hover:not([disabled]),
.carousel-shared-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

.carousel-shared-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

.shared-carousel-wrapper {
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.lib-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16/9;
  min-width: 260px;
  max-width: 320px;
  flex-shrink: 0;
  background: var(--bg-input);
  transition: transform 0.2s, box-shadow 0.2s;
}

.lib-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.lib-card.active {
  box-shadow: 0 0 0 3px var(--accent);
}

.lib-card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.lib-card-collage {
  position: absolute;
  inset: -15%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lib-card-collage img {
  position: absolute;
  width: 45%;
  height: 85%;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 0 4px #000, 0 0 8px #000, 0 0 12px #000, 0 2px 16px #000, 0 4px 24px #000, 0 8px 32px #000, 0 12px 48px #000;
}

/* Scattered poster positions */
.lib-card-collage img:nth-child(1) {
  left: 5%;
  transform: rotate(-6deg);
  z-index: 1;
}
.lib-card-collage img:nth-child(2) {
  left: 22%;
  transform: rotate(3deg);
  z-index: 2;
}
.lib-card-collage img:nth-child(3) {
  left: 40%;
  transform: rotate(-4deg);
  z-index: 3;
}
.lib-card-collage img:nth-child(4) {
  left: 55%;
  transform: rotate(5deg);
  z-index: 4;
}

/* Single poster - fill the card */
.lib-card-collage.posters-1 {
  inset: 0;
}
.lib-card-collage.posters-1 img {
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  transform: none;
  border-radius: 0;
  box-shadow: none;
}

/* Two posters - larger, more spread */
.lib-card-collage.posters-2 img {
  width: 50%;
  height: 90%;
}
.lib-card-collage.posters-2 img:nth-child(1) {
  left: 8%;
  transform: rotate(-7deg);
}
.lib-card-collage.posters-2 img:nth-child(2) {
  left: 42%;
  transform: rotate(5deg);
}

/* Three posters */
.lib-card-collage.posters-3 img {
  width: 45%;
  height: 88%;
}
.lib-card-collage.posters-3 img:nth-child(1) {
  left: 3%;
  transform: rotate(-6deg);
}
.lib-card-collage.posters-3 img:nth-child(2) {
  left: 26%;
  transform: rotate(3deg);
}
.lib-card-collage.posters-3 img:nth-child(3) {
  left: 50%;
  transform: rotate(-4deg);
}

.lib-card-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.placeholder-svg {
  width: 100%;
  height: 100%;
}

.lib-card-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.3) 60%, rgba(0,0,0,0.15) 100%);
}

.lib-card-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
  padding: 0.75rem 1rem;
  text-align: center;
}

.lib-card-name {
  font-weight: 700;
  text-shadow: 0 0 2px #000, 0 0 4px #000, 0 0 8px #000, 0 0 12px #000, 0 0 16px #000, 0 0 24px #000, 0 0 32px #000, 0 0 48px #000, 0 0 64px #000, 0 0 80px #000;
  line-height: 1.2;
  word-break: break-word;
}

.lib-card-count {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 0 2px #000, 0 0 4px #000, 0 0 8px #000, 0 0 12px #000, 0 0 16px #000, 0 0 24px #000, 0 0 32px #000, 0 0 48px #000, 0 0 64px #000, 0 0 80px #000;
  margin-top: 0.25rem;
}

.lib-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 4px;
  z-index: 5;
}

.lib-card:hover .lib-card-actions {
  display: flex;
}

.lib-card-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}

.lib-card-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

.lib-card-btn.edit-btn:hover {
  color: var(--accent);
}

.lib-card-btn.delete-btn:hover {
  color: var(--error);
}

/* --- Forms / Buttons --- */

.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

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

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.new-list-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.new-list-form input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.new-list-form input:focus {
  border-color: var(--accent);
}

.hidden {
  display: none !important;
}

.empty-msg {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 2rem 0;
}

.loading {
  color: var(--text-muted);
  padding: 3rem 0;
  text-align: center;
}

/* --- List View --- */

.movie-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 2.5rem;
}

.movie-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-card);
  border-radius: 6px;
  transition: background 0.15s;
}

.movie-row:hover {
  background: var(--bg-input);
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 0.9rem;
  user-select: none;
  flex-shrink: 0;
}

.movie-row-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.movie-row-img {
  width: 40px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.no-poster-sm {
  width: 40px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.movie-row-title {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movie-row-year {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.remove-btn-row {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.remove-btn-row:hover {
  background: rgba(248, 81, 73, 0.15);
  color: var(--error);
}

/* --- Drag & Drop --- */

.dragging {
  opacity: 0.35;
  box-shadow: 0 0 0 2px var(--accent);
  border-radius: 8px;
  z-index: 10;
}

.movie-list [draggable="true"],
.poster-grid [draggable="true"] {
  transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.movie-list [draggable="true"].dragging,
.poster-grid [draggable="true"].dragging {
  transition: none;
}

/* --- Wishlist Info --- */

.wishlist-info {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 8px;
}

.wishlist-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.wishlist-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* --- Modal --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.modal label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.modal label input,
.modal label textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.modal label input:focus,
.modal label textarea:focus {
  border-color: var(--accent);
}

.modal label input[type="color"] {
  height: 36px;
  padding: 2px 4px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* --- Movie Detail Page --- */

.movie-detail {
  position: relative;
  padding: 0;
  max-width: 100%;
}

.backdrop {
  width: 100%;
  height: 350px;
  background-size: cover;
  background-position: center top;
  position: relative;
}

.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(13, 17, 23, 0.3), var(--bg));
}

.detail-content {
  display: flex;
  gap: 2rem;
  max-width: 1000px;
  margin: -80px auto 0;
  padding: 0 2rem 2rem;
  position: relative;
  z-index: 1;
}

.detail-poster img {
  width: 260px;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.detail-info {
  flex: 1;
  min-width: 0;
  padding-top: 90px;
}

.detail-info h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.detail-year {
  font-weight: 400;
  color: var(--text-muted);
}

.detail-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.detail-tmdb a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.detail-tmdb a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.detail-director,
.detail-cast {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.detail-overview {
  margin-top: 1rem;
  line-height: 1.6;
  font-size: 0.95rem;
}

.add-to-list {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.add-to-list label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* --- Wishlist Picker (detail page) --- */

.wishlist-picker {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.wl-pick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}

.wl-pick-card:hover:not(.disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.wl-pick-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wl-pick-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
}

.wl-thumb-bg {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
}

.wl-thumb-collage {
  width: 100%;
  height: 100%;
  position: relative;
}

.wl-thumb-collage img {
  position: absolute;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
}

.wl-thumb-collage.c1 img { width: 100%; left: 0; }
.wl-thumb-collage.c2 img { width: 50%; }
.wl-thumb-collage.c2 img:nth-child(1) { left: 0; }
.wl-thumb-collage.c2 img:nth-child(2) { left: 50%; }
.wl-thumb-collage.c3 img { width: 34%; }
.wl-thumb-collage.c3 img:nth-child(1) { left: 0; }
.wl-thumb-collage.c3 img:nth-child(2) { left: 33%; }
.wl-thumb-collage.c3 img:nth-child(3) { left: 66%; }
.wl-thumb-collage.c4 img { width: 25%; }
.wl-thumb-collage.c4 img:nth-child(1) { left: 0; }
.wl-thumb-collage.c4 img:nth-child(2) { left: 25%; }
.wl-thumb-collage.c4 img:nth-child(3) { left: 50%; }
.wl-thumb-collage.c4 img:nth-child(4) { left: 75%; }

.wl-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-muted);
}

.wl-pick-name {
  display: block;
  padding: 0.3rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.wl-pick-hint {
  display: block;
  padding: 0 0.4rem 0.3rem;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-style: italic;
}

.add-msg {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.add-msg.success { color: var(--success); }
.add-msg.warn { color: var(--warn); }
.add-msg.error { color: var(--error); }

.error {
  color: var(--error);
  text-align: center;
  padding: 3rem 0;
}

/* --- Login Page --- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-card label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem;
  font-size: 1rem;
}

.login-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.lang-flags {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  padding: 0.4rem 0.75rem;
}

.lang-flag {
  background: none;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  line-height: 0;
  opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s;
}

.lang-flag:hover {
  opacity: 0.8;
}

.lang-flag.active {
  opacity: 1;
  border-color: var(--accent);
}

.login-lang {
  margin-bottom: 1rem;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
}

/* --- Profile Menu --- */

.header-profile {
  position: relative;
}

.profile-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
}

.profile-btn .user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  transition: border-color 0.2s;
}

.profile-btn:hover .user-avatar {
  border-color: var(--accent);
}

.profile-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  min-width: 180px;
  z-index: 300;
  overflow: hidden;
}

.profile-menu-user {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.profile-menu-item {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.profile-menu-item:hover {
  background: var(--bg-input);
}

.profile-menu-logout {
  border-top: 1px solid var(--border);
  color: var(--error);
}

/* --- Share UI --- */

.share-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.share-section > label:first-child {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.share-list {
  margin-bottom: 0.5rem;
}

.share-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.85rem;
}

.share-entry span:nth-child(2) {
  flex: 1;
}

.share-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.share-avatar-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-input);
  flex-shrink: 0;
}

.share-remove-btn {
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
}

.share-global-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.share-global-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* --- Shared Badge --- */

.shared-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* --- Share User Picker --- */

.share-user-picker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.5rem;
}

.share-user-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.share-user-item:hover {
  border-color: var(--accent);
}

.share-user-add {
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}

/* --- Shared Pending Card --- */

.shared-pending-card {
  border: 2px dashed var(--success);
}

/* --- Avatar Fallbacks --- */

.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.avatar-fallback-sm {
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

.avatar-fallback-large {
  font-size: 2.5rem;
}

/* --- Cast Carousel --- */

.cast-carousel-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.cast-carousel-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.cast-carousel-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cast-arrow {
  flex-shrink: 0;
}

.cast-carousel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-behavior: smooth;
  padding-bottom: 0.5rem;
  flex: 1;
  min-width: 0;
}

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

.cast-card {
  flex-shrink: 0;
  width: 120px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}

.cast-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.cast-photo {
  width: 100%;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--bg-input);
}

.cast-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cast-photo .avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 0;
  font-size: 2rem;
}

.cast-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.4rem 0.4rem 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cast-char {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 0 0.4rem 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Person Page --- */

.person-content {
  margin-top: 2rem !important;
}

.person-filmography {
  max-width: 1000px;
  margin: 2rem auto 0;
  padding: 0 2rem 2rem;
}

.person-filmography h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

/* --- Confirm Dialog --- */

.confirm-modal {
  max-width: 320px;
  text-align: center;
}

.confirm-msg {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* --- Responsive --- */

@media (max-width: 700px) {
  header { padding: 0.75rem 1rem; }
  main { padding: 1rem; }
  .poster-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem; }
  .carousel-arrow { display: none; }
  .lib-card { min-width: 200px; }
  .detail-content { flex-direction: column; align-items: center; text-align: center; margin-top: -40px; }
  .detail-poster img { width: 200px; }
  .detail-info { padding-top: 1rem; }
  .detail-meta { justify-content: center; }
  .wishlist-picker { justify-content: center; }
}
