/* ── Reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0d0f14;
  --surface:    #161b25;
  --surface2:   #1e2535;
  --border:     #2a3347;
  --text:       #e8eaf0;
  --text-muted: #8b93a8;
  --accent:     #6c8ef7;
  --accent-dim: #3d4f8a;
  --love:       #ff6b6b;
  --like:       #51cf66;
  --meh:        #fcc419;
  --dislike:    #ff8787;
  --watchlist:  #c084fc;
  --watchlist-dim: #4a1d96;
  --error-bg:   rgba(255,107,107,.10);
  --error-border: rgba(255,107,107,.28);
  --radius:     14px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Screen base ─────────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  padding: 24px 16px;
  max-width: 640px;
  margin: 0 auto;
}
.screen.active { display: flex; flex-direction: column; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active  { transform: scale(.97); }
.btn-primary   { background: var(--accent); color: #fff; width: 100%; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); width: 100%; }
.btn:hover     { opacity: .88; }
.btn:disabled  { opacity: .4; cursor: default; transform: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  width: 100%;
  font-weight: 500;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-text-muted {
  background: none; border: none;
  color: var(--text-muted); font-size: 13px;
  cursor: pointer; padding: 8px 4px;
  text-align: center; width: 100%;
  transition: color .15s;
}
.btn-text-muted:hover { color: var(--text); }

/* ── Auth modal ──────────────────────────────────────────────────────── */
.auth-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-modal[hidden] { display: none; }
.auth-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
}
.auth-modal-box {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
}
.auth-modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none;
  color: var(--text-muted); font-size: 16px;
  cursor: pointer; padding: 4px 8px; border-radius: 8px;
  transition: color .15s;
}
.auth-modal-close:hover { color: var(--text); }
.auth-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border); margin-bottom: 22px;
}
.auth-tab {
  flex: 1; padding: 10px 0;
  background: none; border: none;
  color: var(--text-muted); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: color .15s;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form[hidden] { display: none; }
.auth-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
}
.auth-form input {
  padding: 11px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px;
  outline: none; transition: border-color .15s;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-error {
  background: var(--error-bg); border: 1px solid var(--error-border);
  border-radius: 8px; padding: 9px 12px;
  color: var(--love); font-size: 13px; line-height: 1.4;
}

/* ── Skeleton shimmer ────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skel {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}
.skel-card {
  display: flex; flex-direction: row; align-items: stretch;
  overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 120px; margin-bottom: 14px;
}
.skel-poster {
  width: 100px; min-width: 100px; height: auto;
  border-radius: 0; align-self: stretch;
  min-height: 120px;
}
.skel-body {
  flex: 1; padding: 14px 14px;
  display: flex; flex-direction: column; justify-content: center;
}
.skel-line { display: block; height: 12px; border-radius: 4px; }

.skel-rec-card { min-height: 90px; }
.skel-rec-poster {
  width: 60px; height: 90px;
  border-radius: 8px; flex-shrink: 0;
}
.skel-rec-info { flex: 1; padding: 14px 0 14px 14px; }

/* ── Welcome ─────────────────────────────────────────────────────────── */
#screen-welcome {
  justify-content: center; align-items: center;
  text-align: center; gap: 20px;
}
.logo { font-size: 52px; }
#screen-welcome h1 { font-size: 24px; font-weight: 700; line-height: 1.3; }
#screen-welcome p  { color: var(--text-muted); max-width: 320px; }

/* ── Progress ────────────────────────────────────────────────────────── */
.progress-wrap {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.progress-bar {
  flex: 1; height: 4px;
  background: var(--surface2); border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width .3s ease; width: 0%;
}
.progress-label { color: var(--text-muted); font-size: 13px; white-space: nowrap; }

/* ── Movie card ──────────────────────────────────────────────────────── */
.movie-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: row; align-items: stretch;
  margin-bottom: 14px;
  transition: opacity .15s;
}
.movie-card.loading { opacity: .5; pointer-events: none; }
.movie-poster {
  position: relative; width: 100px; min-width: 100px;
  background: var(--surface2); overflow: hidden; flex-shrink: 0;
}
.movie-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; color: var(--border);
}
.movie-body {
  flex: 1; padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 5px; overflow: hidden;
}
.movie-title    { font-size: 17px; font-weight: 700; line-height: 1.25; }
.movie-meta     { display: flex; flex-wrap: wrap; gap: 4px; color: var(--text-muted); font-size: 12px; }
.movie-meta span::after            { content: "·"; margin-left: 4px; }
.movie-meta span:last-child::after { content: ""; }
.movie-rating   { font-size: 12px; color: var(--meh); }
.movie-synopsis {
  color: var(--text-muted); font-size: 12px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 2px;
}
.stage-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  background: var(--accent-dim); color: var(--accent);
  padding: 3px 9px; border-radius: 20px; margin-bottom: 6px;
}

/* ── Reaction buttons ────────────────────────────────────────────────── */
.reactions {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 8px;
}
.reactions .react-btn:last-child:nth-child(odd) { grid-column: span 2; }
.react-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 8px; min-height: 48px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.react-btn:active  { transform: scale(.97); }
.react-btn:hover   { background: var(--surface2); }
.react-btn:disabled { opacity: .4; cursor: default; transform: none; }
.react-btn.react-btn--ghost { color: var(--text-muted); font-weight: 400; }
.react-btn[data-action="love"]    { color: var(--love); }
.react-btn[data-action="like"]    { color: var(--like); }
.react-btn[data-action="meh"]     { color: var(--meh); }
.react-btn[data-action="dislike"] { color: var(--dislike); }

/* ── Loading ─────────────────────────────────────────────────────────── */
#screen-loading { justify-content: center; align-items: center; gap: 16px; text-align: center; }
.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--surface2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--text); font-weight: 600; }
.loading-sub  { color: var(--text-muted); font-size: 13px; }

/* ── Error banner (inline, non-fatal) ────────────────────────────────── */
.error-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--error-bg); border: 1px solid var(--error-border);
  border-radius: 10px; padding: 12px 14px;
  color: var(--love); font-size: 13px; line-height: 1.4;
}
.error-banner[hidden] { display: none; }
.error-banner-btn {
  background: none; border: 1px solid var(--error-border);
  border-radius: 8px; padding: 5px 12px;
  color: var(--love); font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background .15s;
}
.error-banner-btn:hover { background: rgba(255,107,107,.12); }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 8px; padding: 32px 16px;
}
.empty-state[hidden] { display: none; }
.empty-icon { font-size: 40px; margin-bottom: 4px; }
.empty-state > p     { color: var(--text); font-weight: 600; }
.empty-sub           { color: var(--text-muted); font-size: 13px; }

/* ── Rec idle (auth user, before first load) ─────────────────────────── */
.rec-idle {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 10px; padding: 48px 16px;
}
.rec-idle[hidden] { display: none; }
.rec-idle-icon  { font-size: 48px; margin-bottom: 4px; }
.rec-idle-title { font-size: 18px; font-weight: 700; color: var(--text); margin: 0; }
.rec-idle-sub   { font-size: 14px; color: var(--text-muted); margin: 0; }
.rec-idle-hint  { font-size: 12px; color: var(--text-muted); opacity: 0.6; margin: 4px 0 0; }

/* ── Recommendations ─────────────────────────────────────────────────── */
#screen-recommendations { gap: 16px; }
#screen-recommendations h1 { font-size: 22px; font-weight: 700; }
.rec-list { display: flex; flex-direction: column; gap: 14px; }

.rec-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.rec-card-header { display: flex; gap: 14px; padding: 14px; }
.rec-poster-thumb {
  width: 60px; height: 90px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: var(--surface2); display: flex; align-items: center; justify-content: center;
  color: var(--border); font-size: 26px;
}
.rec-poster-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rec-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.rec-title  { font-size: 15px; font-weight: 700; line-height: 1.3; }
.rec-meta   { font-size: 12px; color: var(--text-muted); }
.rec-rating { font-size: 12px; color: var(--meh); }
.rec-explanation {
  padding: 10px 14px 12px; font-size: 13px; color: var(--text-muted); line-height: 1.6;
  border-top: 1px solid var(--border);
}
.rec-reactions {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 14px 0;
}
.rec-react-btn {
  flex: 1; min-width: 44px; padding: 9px 5px; min-height: 40px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s; text-align: center; white-space: nowrap;
}
.rec-react-btn:hover   { background: var(--surface); }
.rec-react-btn.active  { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.rec-react-btn:disabled { opacity: .4; cursor: default; }

.rec-seen-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px 0; flex-wrap: wrap;
}
.rec-seen-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: none; color: var(--text-muted); font-size: 12px;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.rec-seen-btn:hover  { background: var(--surface); color: var(--text); }
.rec-seen-btn.active { border-color: var(--accent); color: var(--accent); }
.rec-seen-btn:disabled { opacity: .4; cursor: default; }
.rec-watchlist-btn {
  flex: 1; min-width: 120px; margin: 6px 14px 14px;
  padding: 10px; border-radius: 10px; border: 1px dashed var(--border);
  background: transparent; color: var(--text-muted);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s; text-align: center;
}
.rec-watchlist-btn:hover { border-style: solid; color: var(--text); border-color: var(--watchlist); }
.rec-watchlist-btn.active {
  border-style: solid; border-color: var(--watchlist);
  color: var(--watchlist); background: rgba(192,132,252,.08);
}

/* ── App nav bar ─────────────────────────────────────────────────────── */
.app-nav { display: none; }
.app-nav.visible {
  display: flex; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--border);
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.app-nav-inner {
  display: flex; align-items: stretch;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 4px 10px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 11px; font-weight: 500;
  transition: color .15s;
  white-space: nowrap;
}
.nav-btn:hover, .nav-btn.active { color: var(--accent); }
.nav-btn--recs { color: var(--accent); }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; }

.nav-account-dropdown {
  position: absolute; bottom: calc(100% + 4px); right: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  min-width: 180px; z-index: 10;
  box-shadow: var(--shadow);
}
.nav-account-dropdown[hidden] { display: none; }
.nav-dropdown-email {
  font-size: 13px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 10px;
}
.nav-dropdown-logout {
  width: 100%; padding: 8px; border-radius: 8px;
  border: 1px solid var(--border); background: none;
  color: var(--text-muted); font-size: 13px; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-dropdown-logout:hover { background: var(--surface); color: var(--text); }

@media (min-width: 768px) {
  .app-nav.visible {
    top: 0; bottom: auto;
    border-top: none; border-bottom: 1px solid var(--border);
    flex-direction: row; align-items: center; justify-content: center;
    padding: 0 24px; height: 58px;
    padding-bottom: 0;
  }
  .app-nav-inner {
    flex: 1; max-width: 1100px; height: 100%;
    display: flex; align-items: stretch;
  }
  .nav-btn {
    flex-direction: row; gap: 7px; padding: 0 18px;
    font-size: 14px; flex: 0 0 auto;
  }
  .nav-label { font-size: 14px; }
  .nav-icon { font-size: 17px; }
  .nav-account-dropdown {
    top: calc(100% + 4px); bottom: auto; right: 0;
  }
  body.nav-visible { padding-top: 58px; }
}

/* Mobile: push content above tab bar */
@media (max-width: 767px) {
  body.nav-visible #screen-recommendations {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0));
  }
}

/* ── Info sidebar ────────────────────────────────────────────────────── */
.rec-sidebar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; display: none;
}
.rec-sidebar h3 { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.rec-sidebar p  { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }
.rec-sidebar p:last-child { margin-bottom: 0; }
.rec-sidebar ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rec-sidebar li {
  font-size: 13px; color: var(--text-muted); line-height: 1.5;
  padding-left: 18px; position: relative;
}
.rec-sidebar li::before { content: "→"; position: absolute; left: 0; color: var(--accent); }
.sidebar-divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ── Rec mode modal ──────────────────────────────────────────────────── */
.rec-mode-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end;
}
.rec-mode-modal[hidden] { display: none; }
.rec-mode-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); }
.rec-mode-box {
  position: relative; z-index: 1;
  width: 100%; background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 32px;
  max-height: 80vh; overflow-y: auto;
}
.rec-mode-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
}
.rmode-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.rmode-step-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.rmode-choices { display: flex; flex-direction: column; gap: 10px; }
.rmode-choice {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface2); border: 1px solid var(--border);
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color .15s, background .15s;
}
.rmode-choice:hover { border-color: var(--accent); background: var(--accent-dim); }
.rmode-choice-icon { font-size: 28px; flex-shrink: 0; }
.rmode-choice-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.rmode-choice-sub   { font-size: 13px; color: var(--text-muted); }
.rmode-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.rmode-list { display: flex; flex-direction: column; gap: 8px; }
.rmode-two  { display: flex; gap: 10px; }
.rmode-two .rmode-opt { flex: 1; }
.rmode-opt {
  padding: 13px 10px; border-radius: var(--radius);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s; text-align: center; width: 100%;
}
.rmode-opt:hover { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

@media (min-width: 600px) {
  .rec-mode-modal { align-items: center; }
  .rec-mode-box { border-radius: var(--radius); max-width: 440px; max-height: 70vh; margin: 0 auto; }
}

/* ── Profile modal footer ─────────────────────────────────────────────── */
.profile-modal-footer {
  flex-shrink: 0; padding: 12px 16px 20px;
  border-top: 1px solid var(--border);
}
.profile-modal-footer[hidden] { display: none; }

/* ── Profile tab: TG section ─────────────────────────────────────────── */
.ptab-tg-section { margin-top: 4px; }

/* ── Profile tab: history panel ─────────────────────────────────────── */
.stat-cell--clickable { cursor: pointer; transition: background .15s, border-color .15s; }
.stat-cell--clickable:hover { background: var(--surface); border: 1px solid var(--accent); }
.ptab-history-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.ptab-history-back {
  background: none; border: none; color: var(--accent); font-size: 14px;
  cursor: pointer; padding: 4px 0; white-space: nowrap; flex-shrink: 0;
}
.ptab-history-title { font-size: 15px; font-weight: 700; }
.ptab-history-rerate {
  display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px;
}
.ptab-history-btn {
  font-size: 12px; padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--border); background: none;
  color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.ptab-history-btn:hover  { background: var(--surface); color: var(--text); }
.ptab-history-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.ptab-history-item {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.ptab-history-item:last-child { border-bottom: none; }
.ptab-history-info { flex: 1; min-width: 0; }
.ptab-history-movie { font-size: 14px; font-weight: 600; }
.ptab-history-meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ptab-history-list { }
.ptab-history-btn.error { border-color: var(--love); color: var(--love); }
.ptab-history-btn.success { border-color: var(--like); color: var(--like); background: rgba(81,207,102,.12); }

/* ── Onboarding inline account panel ────────────────────────────────── */
.onboarding-account-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
  width: 100%; box-sizing: border-box;
}


/* ── Fatal error screen ──────────────────────────────────────────────── */
#screen-error {
  justify-content: center; align-items: center;
  text-align: center; gap: 14px;
}
.error-icon { font-size: 48px; }
#error-message { color: var(--text-muted); max-width: 300px; line-height: 1.5; }


/* ════════════════════════════════════════════════════════════════════════
   DESKTOP  ≥ 768px
   ════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  #screen-onboarding { max-width: 900px; justify-content: flex-start; }

  .movie-poster    { width: 220px; min-width: 220px; }
  .skel-poster     { width: 220px; min-width: 220px; }
  .movie-body      { padding: 20px 22px; }
  .movie-title     { font-size: 20px; }
  .movie-meta      { font-size: 13px; }
  .movie-synopsis  { -webkit-line-clamp: 6; font-size: 13px; }

  .reactions { grid-template-columns: repeat(5, 1fr); }
  .reactions .react-btn:last-child:nth-child(odd) { grid-column: span 1; }

  #screen-recommendations.active {
    display: grid; max-width: 1100px;
    grid-template-columns: 1fr 300px;
    grid-template-areas:
      "title   sidebar"
      "loading sidebar"
      "banner  sidebar"
      "skel    sidebar"
      "list    sidebar"
      "empty   sidebar"
      "more    .      ";
    column-gap: 28px; align-items: start; min-height: 100vh;
  }
  #screen-recommendations h1  { grid-area: title; }
  #rec-loading                 { grid-area: loading; }
  #rec-error-banner            { grid-area: banner; }
  #rec-list-skeleton           { grid-area: skel; }
  .rec-list                    { grid-area: list; }
  #rec-empty                   { grid-area: empty; }
  #btn-more-recs               { grid-area: more; }
  .rec-sidebar                 { grid-area: sidebar; display: block; position: sticky; top: 82px; }
}

/* ── Profile modal ───────────────────────────────────────────────────── */
.profile-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-end;
}
.profile-modal[hidden] { display: none; }
.profile-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.65);
}
.profile-modal-box {
  position: relative; z-index: 1;
  background: var(--surface); border-radius: 20px 20px 0 0;
  width: 100%; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.profile-modal-header {
  flex-shrink: 0; padding: 16px 16px 0; position: relative;
}
.profile-modal-body {
  flex: 1; overflow-y: auto; padding: 0 16px 8px;
}
@media (min-width: 600px) {
  .profile-modal { align-items: center; justify-content: center; }
  .profile-modal-box {
    border-radius: var(--radius);
    max-width: 520px; max-height: 76vh;
  }
}
.profile-modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
}
.profile-tabs {
  display: flex; gap: 4px; margin-bottom: 16px; margin-top: 4px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.profile-tab {
  background: none; border: none; color: var(--text-muted);
  font-size: 14px; padding: 8px 12px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ptab { flex: 1; }
.ptab[hidden] { display: none; }
.ptab-loading { color: var(--text-muted); font-size: 14px; padding: 24px 0; text-align: center; }
.ptab-empty   { color: var(--text-muted); font-size: 14px; padding: 24px 0; text-align: center; }

/* Profile content */
.profile-notice {
  background: var(--surface2); border-radius: 10px;
  padding: 14px 16px; font-size: 14px; color: var(--text-muted);
}
.profile-section-title {
  font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; margin-top: 16px;
}
.profile-section-title:first-child { margin-top: 4px; }

/* Taste bars */
.taste-bars { display: flex; flex-direction: column; gap: 8px; }
.taste-bar-row {
  display: grid; grid-template-columns: 100px 1fr 36px;
  align-items: center; gap: 10px;
}
.taste-bar-label { font-size: 13px; color: var(--text-muted); }
.taste-bar-track {
  height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden;
}
.taste-bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 3px; transition: width .3s;
}
.taste-bar-value { font-size: 12px; color: var(--text-muted); text-align: right; }

/* Stats grid */
.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.stat-cell {
  background: var(--surface2); border-radius: 10px;
  padding: 10px 8px; text-align: center;
}
.stat-cell-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-cell-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Watchlist / rate list */
.ptab-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.ptab-card {
  background: var(--surface2); border-radius: 10px;
  display: flex; gap: 10px; align-items: flex-start; padding: 10px;
}
.ptab-card-poster {
  width: 44px; height: 64px; border-radius: 6px;
  background: var(--surface); overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text-muted);
}
.ptab-card-poster img { width: 100%; height: 100%; object-fit: cover; }
.ptab-card-body { flex: 1; min-width: 0; }
.ptab-card-title { font-size: 14px; font-weight: 600; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptab-card-meta  { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.ptab-card-synopsis {
  font-size: 12px; color: var(--text-muted); line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ptab-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ptab-card-btn {
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: none;
  color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s;
}
.ptab-card-btn:hover { background: var(--surface); color: var(--text); }
.ptab-card-btn--remove:hover { border-color: var(--love); color: var(--love); }
.ptab-card-btn--love  { border-color: var(--love);   color: var(--love);   }
.ptab-card-btn--like  { border-color: var(--like);   color: var(--like);   }
.ptab-card-btn--meh   { border-color: var(--meh);    color: var(--meh);    }
.ptab-card-btn--dislike { border-color: #888; color: #888; }

/* Rate search */

/* ── S1 → S2 transition overlay ─────────────────────────────────────── */
.s2-transition {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  animation: fadeIn .3s ease;
}
.s2-transition[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.s2-transition-box {
  text-align: center; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.s2-transition-icon { font-size: 52px; }
.s2-transition-box h2 { font-size: 22px; font-weight: 700; }
.s2-transition-box p  { color: var(--text-muted); line-height: 1.6; }
.s2-transition-progress {
  width: 100%; height: 4px; background: var(--border);
  border-radius: 4px; overflow: hidden; margin-top: 8px;
}
.s2-transition-fill {
  height: 100%; width: 0; background: var(--accent);
  border-radius: 4px;
  transition: width 2.2s ease;
}

/* ── Rec inline loading state ────────────────────────────────────────── */
.rec-loading {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 48px 0; text-align: center;
}
.rec-loading[hidden] { display: none; }
.rec-loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.rec-loading-text { font-size: 16px; font-weight: 600; }
.rec-loading-sub  { font-size: 13px; color: var(--text-muted); }

/* ── Compare invite (inside profile tab) ─────────────────────────────── */
.profile-compare-section { margin-top: 18px; }
.compare-invite-result {
  display: flex; gap: 8px; margin-top: 10px; align-items: center;
}
.compare-invite-link {
  flex: 1; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text-muted); font-size: 12px; min-width: 0;
}
.compare-copy-btn { white-space: nowrap; font-size: 13px; padding: 8px 12px; }
.compare-invite-msg { font-size: 12px; margin-top: 6px; color: var(--text-muted); }
.compare-invite-msg.ok  { color: #6fcb6f; }
.compare-invite-msg.err { color: var(--love); }
.compare-invite-result[hidden] { display: none; }
.compare-invite-msg[hidden]    { display: none; }
.profile-compare-section[hidden] { display: none; }

/* ── Compare result modal ─────────────────────────────────────────────── */
.compare-modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: flex-end; justify-content: center;
}
.compare-modal-overlay[hidden] { display: none; }
.compare-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.6);
}
.compare-modal-box {
  position: relative; z-index: 1;
  background: var(--surface); border-radius: 18px 18px 0 0;
  width: 100%; max-width: 520px;
  max-height: 85vh; display: flex; flex-direction: column;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}
.compare-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.compare-modal-title { font-size: 16px; font-weight: 700; }
.compare-modal-body  { flex: 1; overflow-y: auto; padding: 16px 20px 20px; }
.compare-match-block { text-align: center; padding: 12px 0 20px; }
.compare-match-pct   { font-size: 52px; font-weight: 800; color: var(--accent); line-height: 1; }
.compare-match-label { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.compare-section       { margin-bottom: 16px; }
.compare-section-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.compare-film-list     { display: flex; flex-direction: column; gap: 4px; }
.compare-film-row      { font-size: 13px; color: var(--text-muted); }
.compare-film-row strong { color: var(--text); font-weight: 600; }
.compare-together-btn { margin-top: 8px; font-size: 14px; }
.compare-refresh-btn  { margin-top: 8px; font-size: 13px; }

@media (min-width: 600px) {
  .compare-modal-box {
    border-radius: 16px;
    margin-bottom: 40px;
    max-height: 80vh;
  }
}

