/* ── Auth Gate ── */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-gate.hidden { display: none; }

.auth-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(360px, 90vw);
}

.auth-box h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.auth-box input {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

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

.auth-error {
  font-size: 0.82rem;
  color: #ef4444;
}

.auth-error.hidden { display: none; }

/* ── Modals ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal.open { display: flex; }

.modal-box {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  width: min(520px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
}

.modal-box h2 {
  font-size: 1.05rem;
  margin-bottom: 1.25rem;
  font-weight: 700;
}

.modal-box label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.modal-box input[type="text"],
.modal-box select {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  margin-bottom: 0.85rem;
  transition: border-color 0.15s;
  font-family: inherit;
}

.modal-box input[type="text"]:focus,
.modal-box select:focus {
  outline: none;
  border-color: var(--accent);
}

.hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

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

.modal-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

/* ── Search & Add ── */
.search-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-row input { flex: 1; margin: 0; }

.search-results {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.search-result-item:hover { background: var(--card-bg); }

.search-result-item img {
  width: 38px;
  height: 57px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--card-bg);
  flex-shrink: 0;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-info strong {
  display: block;
  font-size: 0.87rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-info span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.add-result-btn {
  background: var(--accent);
  color: var(--accent-dark);
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-size: 0.77rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.15s;
}
.add-result-btn:hover { background: var(--accent-hover); }

.no-results {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 1.25rem 0;
}

/* ── Manual Add ── */
.manual-add {
  margin: 0.5rem 0 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.manual-add summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
  user-select: none;
  padding: 0.3rem 0;
  list-style: none;
}

.manual-add summary::before { content: '+ '; }
.manual-add[open] summary::before { content: '− '; }
.manual-add summary:hover { color: var(--text); }

.manual-fields {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.manual-fields input {
  flex: 1;
  min-width: 90px;
  margin: 0;
}

#manual-year { max-width: 90px; }

/* ── Modal Footer ── */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.add-targets {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.add-targets label { margin: 0; font-size: 0.78rem; white-space: nowrap; }

.add-targets select {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
}

/* ── Lightbox ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 300;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  cursor: zoom-out;
}

.lightbox.open { display: flex; }

.lightbox-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  cursor: default;
  max-width: 90vw;
}

.lightbox-inner img {
  display: block;
  max-width: min(340px, 82vw);
  max-height: 72vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 32px 80px rgba(0,0,0,0.9);
}

.lightbox-ph-icon {
  font-size: 5rem;
  opacity: 0.25;
}

.lightbox-info {
  text-align: center;
}

#lightbox-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

#lightbox-year {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.lightbox-genre {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.5rem;
}

.lightbox-plot {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: left;
  max-width: min(340px, 82vw);
  margin: 0.6rem auto 0;
}

.lightbox-close {
  position: absolute;
  top: -2.25rem;
  right: -0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s;
}

.lightbox-close:hover { color: var(--text); }
