:root {
  --bg: #f4f3f7;
  --surface: #ffffff;
  --surface-2: #faf9fc;
  --border: #e7e5ee;
  --text: #1c1b22;
  --muted: #75737f;
  --accent: #6c5ce7;
  --accent-2: #e26a8d;
  --accent-soft: #ece9fd;
  --accent-ink: #4a3fbf;
  --ok: #1d9e75;
  --danger: #d1495b;
  --shadow: 0 6px 24px rgba(28, 27, 34, 0.07);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131218;
    --surface: #1d1c24;
    --surface-2: #232230;
    --border: #302e3c;
    --text: #ecebf2;
    --muted: #9a98a8;
    --accent: #9d90ff;
    --accent-2: #f08ba9;
    --accent-soft: #2a2547;
    --accent-ink: #c9c0ff;
    --ok: #5dcaa5;
    --danger: #f0879a;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.glow {
  position: fixed;
  inset: 0 0 auto 0;
  height: 340px;
  background:
    radial-gradient(600px 300px at 15% -10%, rgba(108, 92, 231, 0.20), transparent 70%),
    radial-gradient(500px 260px at 90% -20%, rgba(226, 106, 141, 0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.site-header, main, .site-footer { position: relative; z-index: 1; }
.site-header {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 14px; }
.mark { width: 40px; height: 40px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.mark circle { fill: var(--accent); stroke: none; }
.brand-text h1 { font-size: 28px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.tagline { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.auth-area { display: flex; align-items: center; gap: 10px; }
.auth-area .user { font-size: 13.5px; color: var(--text); }
.login-btn {
  display: inline-block; padding: 8px 15px; border-radius: 999px;
  background: var(--accent); color: #fff; text-decoration: none; font-size: 13.5px; font-weight: 500;
}
@media (prefers-color-scheme: dark) { .login-btn { color: #14131a; } }
.login-btn.lg { padding: 11px 22px; font-size: 15px; margin-top: 8px; }
.hero {
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 55%),
    var(--surface);
}
.hero .muted { margin: 0 0 12px; }
.locked { text-align: center; }
.locked .muted { max-width: 460px; margin: 0 auto 14px; }
.regen { width: 100%; margin-top: 14px; }

.tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.tab {
  border: none;
  background: none;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: var(--accent); }
@media (prefers-color-scheme: dark) { .tab.active { color: #14131a; } }

main { max-width: 900px; margin: 0 auto; padding: 20px; }
.panel { display: none; flex-direction: column; gap: 18px; animation: rise 0.35s ease; }
.panel.active { display: flex; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card.accent { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
h2 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.counter { font-size: 13px; color: var(--muted); }

textarea, input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; }
textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.row { display: flex; gap: 10px; margin-top: 10px; }
.row input { flex: 1; }

button {
  padding: 12px 18px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.08s, filter 0.15s, opacity 0.15s;
}
@media (prefers-color-scheme: dark) { button { color: #14131a; } }
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; filter: none; }
button.secondary {
  background: none; color: var(--accent); border: 1px solid var(--border);
  padding: 7px 14px; font-size: 13px;
}
button.primary-lg {
  width: 100%; margin-top: 14px; padding: 13px; font-size: 15px; font-weight: 600;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.status { font-size: 14px; color: var(--muted); margin: 12px 0 0; min-height: 1em; }
.status.err { color: var(--danger); }
.muted { color: var(--muted); font-size: 14px; margin-top: 0; }

.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.example {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 13px; font-size: 12.5px; font-weight: 400;
}
.example:hover { color: var(--accent); border-color: var(--accent); filter: none; }

.themes { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.chip {
  font-size: 13px; padding: 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 500;
}
.chip.neg { background: transparent; border: 1px dashed var(--danger); color: var(--danger); }

.results { margin-top: 4px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.results:empty { display: none; }
.rec {
  display: flex; gap: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.rec:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); transform: translateY(-1px); }
.rec-poster {
  width: 62px; height: 88px; flex-shrink: 0; border-radius: 9px;
  object-fit: cover; display: block; background: var(--surface);
}
.rec-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.rec-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rec-top h3 { margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.rec-top h3 .year { color: var(--muted); font-weight: 400; font-size: 12px; }
.match { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.match.hi { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.match.mid { background: var(--accent-soft); color: var(--accent-ink); }
.match.lo { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.rec .reason {
  font-size: 13px; margin-top: 5px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.rec .meta { font-size: 11.5px; color: var(--muted); margin-top: auto; padding-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* hover actions on a recommendation card */
.rec { position: relative; overflow: hidden; }
.rec-actions {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 6px; padding: 9px 10px;
  background: linear-gradient(transparent, var(--surface-2) 42%);
  transform: translateY(115%); opacity: 0;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.rec:hover .rec-actions, .rec:focus-within .rec-actions { transform: none; opacity: 1; }
.rec-act {
  flex: 1; padding: 7px 6px; font-size: 12px; font-weight: 500; white-space: nowrap;
  border-radius: 9px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
.rec-act:hover { filter: none; }
.rec-act.watched:hover { border-color: var(--ok); color: var(--ok); }
.rec-act.ignore:hover { border-color: var(--danger); color: var(--danger); }
@media (hover: none) { .rec-actions { transform: none; opacity: 1; position: static; background: none; padding: 10px 0 0; } }

/* select + watched form */
select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.watched-body { width: min(400px, 100%); }
.watched-h { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.watched-form { display: flex; flex-direction: column; gap: 13px; margin: 18px 0; }
.watched-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
#watched-msg:empty { display: none; }

.spin { color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.spin::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.site-footer {
  max-width: 900px; margin: 10px auto 40px; padding: 0 20px;
  font-size: 12.5px; color: var(--muted); text-align: center;
}

.icon-btn {
  background: none; color: var(--muted); border: none; padding: 2px 8px;
  border-radius: 8px; font-size: 13px; cursor: pointer;
}
.icon-btn:hover { color: var(--danger); background: var(--surface-2); filter: none; }

.tag-group { margin-top: 16px; }
.tag-head { font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; padding: 4px 6px 4px 11px; border-radius: 999px;
}
.tag.pos { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.tag.neg { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tag-act {
  background: none; border: none; padding: 0 3px; cursor: pointer;
  color: inherit; opacity: 0.6; font-size: 12px; border-radius: 6px;
}
.tag-act:hover { opacity: 1; filter: none; }
.tag-add { display: flex; gap: 8px; margin-top: 10px; }
.tag-add input { flex: 1; padding: 8px 12px; }
.tag-add button { padding: 8px 16px; }
.tag-save-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.tag-save-row .status { margin: 0; }

.favorites { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.favorites:empty { display: none; }
.fav-row { font-size: 13px; color: var(--muted); margin-top: 4px; }
.fav-label { color: var(--text); }

/* ---- catalog: poster gallery ---- */
.catalog-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin-bottom: 4px;
}
.catalog-title { display: flex; align-items: baseline; gap: 10px; }
.catalog-title h2 { font-size: 18px; }
#catalog-search { max-width: 320px; padding: 9px 13px; }
.poster-grid {
  display: grid; gap: 16px; margin-top: 14px;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
}
.poster-card { margin: 0; cursor: pointer; }
.poster-wrap {
  position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
}
.poster-card:hover .poster-wrap {
  transform: translateY(-3px); box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.poster-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.score-badge {
  position: absolute; left: 8px; bottom: 8px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: rgba(10, 9, 15, 0.72); color: #fff; backdrop-filter: blur(2px);
}
.kind-badge {
  position: absolute; left: 8px; top: 8px;
  font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  background: rgba(108, 92, 231, 0.85); color: #fff; letter-spacing: 0.02em;
}
.catalog-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-top: 4px;
}
.catalog-hint .muted { margin: 0; }
#catalog-status:empty { display: none; }
.catalog-more { display: flex; justify-content: center; margin-top: 18px; }
.catalog-more button { min-width: 200px; }
.catalog-more button[hidden] { display: none; }
.poster-card figcaption { margin-top: 7px; display: flex; flex-direction: column; gap: 1px; }
.poster-name {
  font-size: 13px; font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.poster-year { font-size: 11.5px; color: var(--muted); }

/* image-less fallback (grid + rec thumbnails) */
.noimg {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
}
.noimg::after {
  content: attr(data-letter); font-size: 26px; font-weight: 700;
  color: var(--accent); text-transform: uppercase; opacity: 0.6;
}
.rec-poster.noimg::after { font-size: 20px; }

.badge {
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap;
}

.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 9, 15, 0.55); backdrop-filter: blur(2px); }
.modal-body {
  position: relative; z-index: 1; width: min(720px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.modal-close {
  position: absolute; top: 14px; right: 14px; background: var(--surface-2);
  color: var(--muted); border: 1px solid var(--border); border-radius: 999px;
  width: 30px; height: 30px; padding: 0; cursor: pointer;
}
.modal-close:hover { color: var(--text); filter: none; }
.title-card { display: flex; gap: 22px; align-items: flex-start; }
.poster { width: 200px; border-radius: 12px; flex-shrink: 0; object-fit: cover; align-self: flex-start; }
.title-info { min-width: 0; flex: 1; }
.title-info h3 { margin: 0 0 2px; font-size: 19px; font-weight: 600; line-height: 1.25; }
.subtitle { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.title-meta { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.title-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.title-desc { font-size: 13.5px; line-height: 1.55; margin: 0 0 4px; }
.title-links { display: flex; gap: 16px; margin: 14px 0 10px; flex-wrap: wrap; }
.title-links a { font-size: 13.5px; color: var(--accent); text-decoration: none; }
.title-links a.ali { color: var(--accent-2); }
.title-links a:hover { text-decoration: underline; }
.sub-btn {
  padding: 9px 15px; font-size: 13.5px; background: var(--surface-2);
  color: var(--accent); border: 1px solid var(--border);
}
.sub-btn:hover { border-color: var(--accent); filter: none; }
.sub-status { display: block; margin-top: 8px; font-size: 12.5px; color: var(--muted); }

.regen { width: 100%; margin-top: 14px; }

.subs-list { list-style: none; padding: 0; margin: 12px 0 0; }
.subs-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.subs-list li:last-child { border-bottom: none; }

@media (max-width: 620px) {
  .site-header { padding-top: 28px; gap: 14px; }
  .tabs { width: 100%; }
  .tab { flex: 1; text-align: center; }
  .results { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
  .modal-body { padding: 18px; }
  .title-card { flex-direction: column; align-items: center; text-align: left; }
  .poster { width: 170px; }
  .title-info { width: 100%; }
}
