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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f0f14;
  color: #e8e8ee;
  min-height: 100vh;
  padding-bottom: 40px;
}

header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  padding: 24px 32px;
  border-bottom: 1px solid #2a2a3e;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

h1 {
  font-size: 28px;
  margin-bottom: 16px;
  background: linear-gradient(90deg, #ff6b6b, #ffd93d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.topbar-btn {
  background: #2a2a3e;
  color: #e8e8ee;
  border: 1px solid #353555;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.topbar-btn:hover { background: #353555; }

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

.tab-btn {
  background: #252540;
  color: #b8b8c8;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.tab-btn:hover { background: #353555; color: #fff; }
.tab-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

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

.tab-content { display: none; }
.tab-content.active { display: block; }

h2 {
  font-size: 22px;
  margin-bottom: 20px;
  color: #fff;
}

.form-card {
  background: #1a1a2e;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid #2a2a3e;
}

.form-card input[type="text"],
.form-card input[type="number"],
.form-card input[type="url"],
.form-card input[type="file"],
.form-card select {
  background: #0f0f14;
  border: 1px solid #2a2a3e;
  color: #e8e8ee;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.form-card input:focus, .form-card select:focus {
  outline: none;
  border-color: #667eea;
}

.photo-input {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.photo-input > * { flex: 1; min-width: 200px; }

.form-card label {
  font-size: 13px;
  color: #b8b8c8;
  margin-top: 4px;
}

.actor-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 120px;
  overflow-y: auto;
  background: #0f0f14;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #2a2a3e;
}

.actor-checkboxes label {
  background: #252540;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #e8e8ee;
  display: flex;
  align-items: center;
  gap: 6px;
}

.actor-checkboxes label:hover { background: #353555; }
.actor-checkboxes input[type="checkbox"] { cursor: pointer; }

.form-card button[type="submit"] {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}
.form-card button[type="submit"]:hover { transform: translateY(-1px); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.card {
  background: #1a1a2e;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #2a2a3e;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
}

.card-img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  background: #0f0f14;
}

.card-img.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: #353555;
}

.card-body { padding: 14px; flex: 1; display: flex; flex-direction: column; }

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #fff;
}

.card-meta {
  font-size: 12px;
  color: #8888a0;
  margin-bottom: 10px;
}

.card-actors {
  font-size: 12px;
  color: #b8b8c8;
  margin-bottom: 10px;
  font-style: italic;
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.status-badge.watching { background: #f59e0b; color: #000; }
.status-badge.watched { background: #10b981; color: #000; }
.status-badge.dropped { background: #ef4444; color: #fff; }

.rewatch-badge {
  display: inline-block;
  background: #6366f1;
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  margin-left: 6px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.se-badge {
  display: inline-block;
  background: #f59e0b;
  color: #000;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
  margin-left: 6px;
  font-family: monospace;
}

/* Сейчас смотрю widget */
.watching-now {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(102, 126, 234, 0.05));
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}
.watching-now h3 {
  color: #f59e0b;
  font-size: 16px;
  margin-bottom: 12px;
}
.watching-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}
.watching-scroll::-webkit-scrollbar { height: 6px; }
.watching-scroll::-webkit-scrollbar-thumb { background: #353555; border-radius: 3px; }

.watching-card {
  flex: 0 0 220px;
  background: #1a1a2e;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid rgba(245, 158, 11, 0.5);
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
  transition: transform 0.1s;
}
.watching-card:hover { transform: translateY(-3px); border-color: #f59e0b; }
.watching-card .card-img, .watching-card .placeholder {
  width: 100%;
  height: 280px;
  object-fit: cover;
}
.watching-card-body { padding: 10px; }
.watching-card-title {
  font-size: 14px;
  color: #fff;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.watching-card-progress {
  font-size: 12px;
  color: #f59e0b;
  font-family: monospace;
  margin-bottom: 8px;
  font-weight: 700;
}
.watching-card-actions {
  display: flex;
  gap: 6px;
}
.watching-card-actions button {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.tag-chip {
  background: rgba(102, 126, 234, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(102, 126, 234, 0.4);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 500;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.card-actions button {
  flex: 1;
  min-width: 60px;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: #252540;
  color: #e8e8ee;
  transition: background 0.15s;
}

.card-actions button:hover { background: #353555; }
.card-actions .btn-watching { background: #f59e0b; color: #000; }
.card-actions .btn-watched { background: #10b981; color: #000; }
.card-actions .btn-dropped { background: #ef4444; color: #fff; }
.card-actions .btn-archive { background: #667eea; color: #fff; }
.card-actions .btn-delete { background: #7f1d1d; color: #fff; }
.card-actions .btn-clear { background: #4a4a5e; color: #fff; }
.card-actions .btn-play { background: #dc2626; color: #fff; }
.card-actions .btn-kp { background: #ff5500; color: #fff; }
.card-actions .btn-fetch { background: #0ea5e9; color: #fff; }

/* Actor cards */
.actor-card { position: relative; }
.actor-card.selected { outline: 3px solid #ffd93d; outline-offset: -3px; }

.card-fav, .card-select {
  position: absolute;
  top: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  background: rgba(15, 15, 20, 0.85);
  color: #fff;
  transition: transform 0.1s;
}
.card-fav:hover, .card-select:hover { transform: scale(1.1); }
.card-fav { right: 8px; }
.card-select { left: 8px; }
.card-fav.on { background: #ffd93d; color: #000; }
.card-select.on { background: #ffd93d; color: #000; }

.compare-bar {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid #ffd93d;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  color: #ffd93d;
  font-size: 14px;
}

.actor-films-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.mini-card {
  background: #0f0f14;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.mini-card:hover { transform: translateY(-2px); border-color: #667eea; }
.mini-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.mini-placeholder {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #353555;
  background: #1a1a2e;
}
.mini-title {
  padding: 6px 8px 2px;
  font-size: 12px;
  color: #fff;
  font-weight: 500;
  line-height: 1.3;
}
.mini-year {
  padding: 0 8px 6px;
  font-size: 11px;
  color: #8888a0;
}

/* Actor mini avatars on movie cards */
.card-actors-mini {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.actor-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #2a2a3e;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
  background: #0f0f14;
}
.actor-avatar:hover { transform: scale(1.15); border-color: #ffd93d; z-index: 1; }
.actor-avatar-placeholder {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #353555;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  border: 2px solid #2a2a3e;
  cursor: pointer;
}
.actor-avatar-placeholder:hover { transform: scale(1.15); border-color: #ffd93d; }
.actor-more {
  font-size: 11px;
  color: #8888a0;
  margin-left: 4px;
}

/* Actor cards in movie modal */
.actor-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.actor-card-mini {
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s;
}
.actor-card-mini:hover { transform: translateY(-2px); }
.actor-card-mini img {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  background: #0f0f14;
}
.actor-card-mini .placeholder-block {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 8px;
  background: #353555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
}
.actor-card-mini .name {
  font-size: 12px;
  margin-top: 4px;
  color: #e8e8ee;
  line-height: 1.3;
}
.actor-card-mini .fav {
  color: #ffd93d;
  margin-left: 2px;
}

.card-title a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed #667eea;
}
.card-title a:hover { color: #ffd93d; }

.note-text {
  font-size: 11px;
  color: #ffd93d;
  background: rgba(255, 217, 61, 0.08);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.rating input {
  width: 60px;
  background: #0f0f14;
  border: 1px solid #2a2a3e;
  color: #ffd93d;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
}
.rating .star { color: #ffd93d; font-size: 14px; }

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar input, .filter-bar select {
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  color: #e8e8ee;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  flex: 1;
  min-width: 150px;
}

.filter-btn {
  background: #252540;
  color: #b8b8c8;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.filter-btn:hover { background: #353555; color: #fff; }
.filter-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

.stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat-card {
  background: #1a1a2e;
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px solid #2a2a3e;
  flex: 1;
  min-width: 140px;
}

.stat-card .num {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(90deg, #ff6b6b, #ffd93d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-card .label {
  font-size: 12px;
  color: #8888a0;
  text-transform: uppercase;
}

.empty {
  text-align: center;
  padding: 40px;
  color: #8888a0;
  font-style: italic;
  grid-column: 1 / -1;
}

.card-body { cursor: pointer; }
.card-actions, .rating { cursor: default; }

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadein 0.15s;
}
.modal-backdrop[hidden] { display: none !important; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #1a1a2e;
  border-radius: 16px;
  border: 1px solid #353555;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #2a2a3e;
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}
.modal-close:hover { background: #ef4444; }

.modal-poster {
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: 10px;
  background: #0f0f14;
  margin-bottom: 16px;
}

.modal h3 {
  font-size: 24px;
  margin-bottom: 8px;
  color: #fff;
}

.modal-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 13px;
  color: #8888a0;
}

.modal-field {
  margin-bottom: 14px;
}
.modal-field label {
  display: block;
  font-size: 12px;
  color: #8888a0;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.modal-field input, .modal-field textarea, .modal-field select {
  width: 100%;
  background: #0f0f14;
  border: 1px solid #2a2a3e;
  color: #e8e8ee;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.modal-field textarea { resize: vertical; min-height: 60px; }
.modal-field .description {
  color: #b8b8c8;
  line-height: 1.5;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.modal-actions button {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.modal-actions .btn-watching { background: #f59e0b; color: #000; }
.modal-actions .btn-watched { background: #10b981; color: #000; }
.modal-actions .btn-dropped { background: #ef4444; color: #fff; }
.modal-actions .btn-clear { background: #4a4a5e; color: #fff; }
.modal-actions .btn-delete { background: #7f1d1d; color: #fff; margin-left: auto; }
.modal-actions .btn-play { background: #dc2626; color: #fff; }
.modal-actions .btn-kp { background: #ff5500; color: #fff; }

.modal-actors-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #0f0f14;
  border: 1px solid #2a2a3e;
  padding: 10px;
  border-radius: 6px;
  max-height: 140px;
  overflow-y: auto;
}
.modal-actors-edit label {
  background: #252540;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
}
