:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --fg: #eef1f6;
  --muted: #9aa4b2;
  --accent: #e5a00d;   /* Plex-ish amber */
  --accent-2: #f7c744;
  --error: #ff6b6b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2130 0%, var(--bg) 60%);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

#app { width: 100%; max-width: 640px; }

.view { text-align: center; }

h1 { font-size: clamp(1.7rem, 6vw, 2.6rem); margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 28px; font-size: 1.02rem; }

#login-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

#username {
  padding: 14px 18px;
  font-size: 1.1rem;
  border: 1px solid #2a3240;
  background: var(--panel);
  color: var(--fg);
  border-radius: 10px;
  min-width: 240px;
  flex: 1;
  outline: none;
}
#username:focus { border-color: var(--accent); }

#login-btn {
  padding: 14px 26px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #1a1400;
  cursor: pointer;
}
#login-btn:disabled { opacity: .6; cursor: default; }

.error { color: var(--error); margin-top: 16px; min-height: 1.2em; }

/* Recommendations header */
.recs-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 22px; text-align: left; gap: 12px; flex-wrap: wrap;
}
.recs-head h2 { margin: 0; font-size: 1.5rem; }
#who { color: var(--accent-2); }
#change-user { color: var(--muted); font-size: .9rem; text-decoration: none; }
#change-user:hover { color: var(--fg); }

/* Card grid: capped size, centered, wraps to a single column when narrow */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 220px));
  gap: 22px;
  justify-content: center;
}

.card {
  background: var(--panel);
  border-radius: 14px;
  overflow: hidden;
  text-align: left;
  border: 1px solid #232a36;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.poster { position: relative; aspect-ratio: 2 / 3; background: #0a0c10; }
.poster img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .35s ease;
}
.card:not(.loading) .poster img { opacity: 1; }

/* Thinking state: shimmer sweep + pulsing dots */
.skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, #0d1017 30%, #1e2634 50%, #0d1017 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 220% 0; }
  100% { background-position: -220% 0; }
}
.thinking {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  gap: 7px;
}
.thinking span {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  animation: bounce 1s infinite ease-in-out;
}
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-8px); opacity: 1; }
}
.card:not(.loading) .skeleton,
.card:not(.loading) .thinking { display: none; }

.meta { padding: 14px 16px 18px; }
.kind {
  display: inline-block; font-size: .68rem; letter-spacing: .08em;
  text-transform: uppercase; color: #1a1400; background: var(--accent);
  padding: 3px 8px; border-radius: 6px; margin-bottom: 8px;
}
.title { margin: 4px 0 8px; font-size: 1.12rem; line-height: 1.25; }
.reason { margin: 0; color: var(--muted); line-height: 1.45; font-size: .92rem; }

/* Skeleton text bars while loading */
.card.loading .title,
.card.loading .reason { color: transparent; border-radius: 6px; animation: pulse 1.3s infinite; }
.card.loading .title { background: #1e2634; min-height: 1.1em; width: 70%; }
.card.loading .reason { background: #161b26; min-height: 2.7em; }
@keyframes pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

.actions { display: flex; gap: 8px; margin-top: 14px; }
.card.loading .actions { visibility: hidden; }
.actions button {
  flex: 1; padding: 10px 6px; font-size: .82rem; font-weight: 600;
  border-radius: 8px; cursor: pointer; min-height: 40px;
}
.actions .seen { background: #2a3240; color: var(--fg); border: 1px solid #2a3240; }
.actions .seen:hover { background: #343d4d; }
.actions .nope { background: transparent; color: var(--muted); border: 1px solid #2a3240; }
.actions .nope:hover { color: var(--fg); border-color: #3a4454; }

@media (max-width: 400px) {
  .actions { flex-direction: column; }
}
