:root {
  --bg: #0a0c13;
  --bg-elev: #121624;
  --bg-card: #161b2c;
  --bg-hover: #1d2438;
  --border: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(230, 184, 79, 0.35);
  --text: #f3efe6;
  --text-muted: #9aa3b8;
  --gold: #e6b84f;
  --gold-bright: #f5cd6d;
  --gold-soft: rgba(230, 184, 79, 0.14);
  --crimson: #e05363;
  --emerald: #34c785;
  --emerald-soft: rgba(52, 199, 133, 0.16);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top center, #151b2e 0%, var(--bg) 52%);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(10, 12, 19, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold) 0%, #b57c1d 100%);
  color: #141007;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(230, 184, 79, 0.28);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  color: var(--text);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: #161106;
}

.btn-gold:hover {
  filter: brightness(1.06);
}

.btn-primary {
  background: #273252;
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-primary:hover {
  background: #314068;
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
}

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

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(224, 83, 99, 0.16);
  border-color: rgba(224, 83, 99, 0.4);
  color: #ff94a0;
}

.btn-danger:hover {
  background: rgba(224, 83, 99, 0.28);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.82rem;
}

/* Main */
.main-content {
  padding-top: 22px;
  padding-bottom: 56px;
}

/* Stats Panel */
.stats-panel {
  display: grid;
  grid-template-columns: 1.5fr 2fr;
  gap: 16px;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 9px;
  gap: 10px;
}

.progress-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 600;
}

.progress-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, #f6d57a 100%);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.stat-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.stat-lbl {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Controls */
.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

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

.pill {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.pill:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.pill.active {
  background: var(--gold-soft);
  border-color: var(--border-gold);
  color: var(--gold-bright);
}

.filter-inputs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.search-wrap {
  flex: 1 1 240px;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
}

.filter-inputs select {
  width: auto;
  flex: 0 1 auto;
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1rem;
}

.icon-btn.active {
  background: var(--gold-soft);
  color: var(--gold-bright);
}

/* Subbar */
.subbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 0.84rem;
  gap: 10px;
  flex-wrap: wrap;
}

.text-link {
  color: var(--text-muted);
  text-decoration: none;
}

.text-link:hover {
  color: var(--gold-bright);
}

.dot {
  color: var(--text-muted);
  margin: 0 6px;
}

/* Empty state */
.empty-state {
  text-align: center;
  background: var(--bg-elev);
  border: 1px dashed var(--border-gold);
  border-radius: var(--radius);
  padding: 48px 24px;
}

.empty-icon {
  font-size: 2.8rem;
  margin-bottom: 10px;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-family: "Playfair Display", Georgia, serif;
}

.empty-state p {
  max-width: 520px;
  margin: 0 auto 22px;
  color: var(--text-muted);
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Movies Grid */
.movies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
}

.movie-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
}

.movie-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-gold);
  box-shadow: var(--shadow);
}

.poster-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  background: linear-gradient(155deg, #1b2238 0%, #0e111c 100%);
  overflow: hidden;
}

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

.poster-fallback {
  width: 100%;
  height: 100%;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: radial-gradient(circle at 30% 20%, rgba(230, 184, 79, 0.16), transparent 60%),
              linear-gradient(160deg, #1c2236 0%, #0d1019 100%);
  border-bottom: 1px solid var(--border);
}

.poster-fallback-star {
  color: var(--gold);
  font-size: 1.5rem;
  margin-bottom: 10px;
  opacity: 0.8;
}

.poster-fallback-title {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.poster-fallback-year {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--gold);
}

.badge-top-left {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.badge-watched {
  background: rgba(16, 46, 33, 0.88);
  color: #6df0b3;
  border: 1px solid rgba(52, 199, 133, 0.45);
}

.badge-mustsee {
  background: rgba(45, 34, 10, 0.88);
  color: var(--gold-bright);
  border: 1px solid var(--border-gold);
}

.card-quick-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 5px;
}

.quick-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 12, 19, 0.78);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 0.88rem;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.quick-btn:hover {
  transform: scale(1.08);
  color: var(--text);
}

.quick-btn.is-fav {
  color: var(--crimson);
  border-color: rgba(224, 83, 99, 0.5);
}

.quick-btn.is-watched {
  color: var(--emerald);
  border-color: rgba(52, 199, 133, 0.5);
}

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

.card-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.3;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-footer {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 0.73rem;
}

.rating-pill {
  font-weight: 700;
  color: var(--gold-bright);
  background: var(--gold-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Compact List View */
.movies-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-row {
  display: grid;
  grid-template-columns: 44px 1.8fr 0.9fr 0.9fr 0.8fr auto;
  gap: 12px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.list-row:hover {
  border-color: var(--border-gold);
  background: var(--bg-hover);
}

.list-thumb {
  width: 44px;
  height: 62px;
  border-radius: 6px;
  object-fit: cover;
  background: #1c2236;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  color: var(--gold);
}

.list-actions {
  display: flex;
  gap: 6px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 6, 11, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
}

.modal {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 780px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.35rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

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

.modal-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.span-2 {
  grid-column: span 2;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 6px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.checkbox-field label {
  flex-direction: row;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--gold);
}

.modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.modal-footer-actions.spread {
  justify-content: space-between;
}

.btn-group {
  display: flex;
  gap: 8px;
}

/* Lookup Box */
.lookup-box {
  background: rgba(230, 184, 79, 0.06);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.lookup-box label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold-bright);
  margin-bottom: 8px;
}

.lookup-row {
  display: flex;
  gap: 8px;
}

.lookup-results {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.lookup-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
}

.lookup-item:hover {
  border-color: var(--gold);
  background: var(--bg-hover);
}

.lookup-item img {
  width: 38px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.lookup-item-title {
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.25;
}

.lookup-item-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Detail modal */
.detail-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
}

.detail-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.detail-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.scores-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.score-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.score-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-bright);
}

.score-lbl {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.detail-section {
  margin-top: 12px;
}

.detail-section h4 {
  margin: 0 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gold);
}

.detail-section p {
  margin: 0;
  font-size: 0.92rem;
  white-space: pre-wrap;
}

.quote-box {
  margin-top: 12px;
  padding: 10px 14px;
  border-left: 3px solid var(--gold);
  background: rgba(230, 184, 79, 0.06);
  font-style: italic;
  border-radius: 0 8px 8px 0;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Private gate */
.private-gate {
  display: flex;
  justify-content: center;
  padding: 60px 16px;
}

.private-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.error-text {
  color: #ff8e9b;
  font-size: 0.85rem;
  margin: 8px 0 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 80;
  background: #1d2438;
  border: 1px solid var(--border-gold);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 500;
  max-width: 380px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 18px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 860px) {
  .stats-panel {
    grid-template-columns: 1fr;
  }
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .detail-poster {
    max-width: 220px;
    margin: 0 auto;
  }
  .list-row {
    grid-template-columns: 40px 1fr auto;
  }
  .list-hide-sm {
    display: none;
  }
}

@media (max-width: 560px) {
  .movies-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .stat-chips {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: span 1;
  }
}
