:root {
  --bg: #0B0D12;
  --panel: #14171F;
  --border: #232733;
  --text: #EDEDF0;
  --muted: #8A8F9C;
  --gold: #E3A857;
  --gold-text: #1A1305;
  --teal: #2FBFA3;
  --teal-text: #04211C;
  --danger: #E0684F;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

.hidden { display: none !important; }

.screen { min-height: 100vh; position: relative; }

/* ---------- ambient background ---------- */
#bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 900px 600px at 15% -10%, rgba(227,168,87,0.10), transparent 60%),
    radial-gradient(ellipse 800px 700px at 110% 10%, rgba(47,191,163,0.09), transparent 55%),
    radial-gradient(ellipse 700px 500px at 50% 120%, rgba(227,168,87,0.06), transparent 60%);
}

.bg-star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  animation-name: star-twinkle;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}

@keyframes star-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.7); }
  50% { opacity: 0.85; transform: scale(1); }
}

.screen > * { position: relative; z-index: 1; }

/* ---------- login ---------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 0 24px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.login-logo-ring {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo-ring::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(227,168,87,0.35);
  border-top-color: rgba(47,191,163,0.55);
  animation: ring-spin 14s linear infinite;
}
.login-logo-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 0 24px rgba(227,168,87,0.18);
}

@keyframes ring-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.brand-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 48px;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
}

.brand-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 32px;
}

#login-form { display: flex; flex-direction: column; gap: 12px; }

#code-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 6px;
  text-align: center;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  outline: none;
}

.error-text { color: var(--danger); font-size: 13px; margin: 0; }

.btn-gold {
  background: var(--gold);
  color: var(--gold-text);
  border: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-gold:hover { opacity: 0.9; }
.btn-block { width: 100%; padding: 13px; }
.btn-small { padding: 8px 14px; display: flex; align-items: center; gap: 6px; }

.btn-teal {
  background: var(--teal);
  color: var(--teal-text);
  border: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
}
.btn-teal:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

.poster-picker-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.poster-picker {
  flex-shrink: 0;
  width: 64px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--panel);
}
.poster-picker img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-picker-meta { flex: 1; min-width: 0; padding-top: 2px; }
.poster-picker-actions { display: flex; gap: 8px; }

/* ---------- header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11,13,18,0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mini { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.brand-icon-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}
.brand-mini-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 0.06em;
}

.search-wrap {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px 0 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(227,168,87,0.12);
}
.search-icon {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  color: var(--muted);
}
#search-input {
  flex: 1;
  width: 100%;
  padding: 10px 8px;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
}
#search-input::placeholder { color: var(--muted); }
.search-clear {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover { opacity: 0.8; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 6px;
  background: var(--panel);
  flex-shrink: 0;
}
.tabs-inset { background: var(--bg); width: fit-content; }

.tab-btn {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tab-btn.active { background: var(--gold); color: var(--gold-text); }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.role-badge { display: flex; align-items: center; gap: 4px; }
.role-badge.admin { color: var(--teal); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
}
.icon-btn:hover { opacity: 0.7; }

/* ---------- main ---------- */
.app-main { max-width: 900px; margin: 0 auto; padding: 40px 20px; }

.center-state { text-align: center; padding: 96px 0; }
.idle-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.idle-title.small { font-size: 26px; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
.small-label { font-size: 12px; margin-bottom: 16px; }

.results-list { display: flex; flex-direction: column; gap: 8px; }

.result-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}
.result-card:hover { filter: brightness(1.1); }

.result-icon {
  flex-shrink: 0;
  width: 64px;
  height: 44px;
  border-radius: 6px;
  background: rgba(227,168,87,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  overflow: hidden;
}
.poster-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.result-info { flex: 1; min-width: 0; }
.result-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-type { font-size: 12px; color: var(--muted); }
.result-play { color: var(--muted); font-size: 16px; }

.no-results-inner { max-width: 420px; margin: 0 auto; padding: 48px 0; }
#no-results-query { color: var(--text); }

.request-sent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--teal);
  border: 1px solid var(--border);
  font-size: 14px;
}

#request-form { display: flex; flex-direction: column; gap: 12px; }
#request-query-display {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  opacity: 0.7;
}
#request-note {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  outline: none;
  resize: none;
  font-family: inherit;
}

/* ---------- manage view ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 0.05em;
  margin: 0;
}
.saving { font-size: 12px; opacity: 0.6; font-family: 'Inter', sans-serif; letter-spacing: 0; }

.upload-form {
  padding: 16px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.field-label input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  outline: none;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--gold);
  background: rgba(227,168,87,0.06);
}
.drop-zone-icon { font-size: 20px; color: var(--muted); margin-bottom: 6px; }
.drop-zone-text { color: var(--muted); font-size: 13px; }

.drop-zone-selected {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: default;
}
.drop-zone-meta { flex: 1; min-width: 0; }
.drop-zone-filename {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  word-break: break-all;
}
.drop-zone-remove {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.drop-zone-remove:hover { opacity: 0.8; }

.library-list { display: flex; flex-direction: column; gap: 6px; }

.library-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 14px;
}
.library-row .row-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-row .row-icon {
  flex-shrink: 0;
  width: 34px;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: rgba(227,168,87,0.1);
}
.library-row .row-icon .poster-img { border-radius: 4px; }
.library-row button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
}
.library-row.fulfilled { opacity: 0.55; }
.library-row .strike { text-decoration: line-through; }
.empty-note { text-align: center; padding: 24px 0; color: var(--muted); font-size: 14px; }

/* ---------- watch view ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5,6,9,0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlay-in 0.15s ease-out;
}
@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.watch-box {
  position: relative;
  width: 95vw;
  max-width: 1150px;
  height: 85vh;
  max-height: 720px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
}

.watch-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  background: rgba(0,0,0,0.55);
  border: none;
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.watch-close:hover { background: rgba(0,0,0,0.75); }

.watch-video-pane {
  flex: 1 1 65%;
  min-width: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.watch-video-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.download-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 30px;
}
.download-poster {
  max-width: 280px;
  max-height: 45vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
}
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 26px;
  text-decoration: none;
}
.download-btn svg { width: 18px; height: 18px; }

.watch-side-pane {
  flex: 0 0 320px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

.watch-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 0.04em;
  line-height: 1.15;
  margin-bottom: 4px;
}
.watch-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
}

.season-select {
  display: block;
  width: 100%;
  margin: -8px 0 14px;
  padding: 9px 32px 9px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  border-radius: 7px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.season-select:hover,
.season-select:focus {
  border-color: var(--gold);
  outline: none;
}

.related-list { display: flex; flex-direction: column; gap: 6px; }

.related-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
}
.related-item:hover { border-color: var(--gold); }
.related-item.active {
  border-color: var(--gold);
  background: rgba(227,168,87,0.08);
}
.r-icon {
  flex-shrink: 0;
  width: 38px;
  height: 26px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: rgba(227,168,87,0.1);
}
.r-title {
  font-size: 13px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .watch-box { flex-direction: column; height: 92vh; max-height: none; }
  .watch-video-pane { flex: 0 0 42%; }
  .watch-side-pane { flex: 1; border-left: none; border-top: 1px solid var(--border); }
}
