:root {
  --bg: #111318;
  --surface: #1b1e26;
  --surface-2: #252a34;
  --border: #2f3542;
  --text: #eef0f4;
  --muted: #9aa3b2;
  --accent: #f5b301;
  --accent-text: #1a1400;
  --danger: #ff6b6b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.2; margin: 0 0 .4rem; }
h2 { font-size: 1.25rem; margin: 1.8rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .3rem; }
p { margin: .4rem 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--danger); }
.hint { color: var(--muted); font-size: .8rem; margin-top: 1rem; }
.original { font-style: italic; margin-top: -.2rem; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px;
  /* Instalada en iPhone, la barra queda debajo del reloj y la cámara. */
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab {
  color: var(--muted); text-decoration: none; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .95rem;
}
.tab:hover { color: var(--text); background: var(--surface); }
.tab.active { color: var(--accent-text); background: var(--accent); }
.badge {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  font-size: .75rem; background: var(--surface-2); color: var(--text);
}
.tab.active .badge { background: rgba(0,0,0,.18); color: var(--accent-text); }

/* ---------- Cuenta ---------- */
.topbar-end { margin-left: auto; display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; flex: 1 1 0; }
.brand { flex: none; }
.account-slot { display: flex; align-items: center; min-width: 0; }
.region-button {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer;
}
.region-button .flag { font-size: 1.3rem; line-height: 1; }
.region-button .region-code { font-size: .8rem; font-weight: 700; color: var(--muted); }
/* El select invisible cubre la bandera: al tocarla se abre la lista nativa de países. */
.region-button select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.region-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Plataformas ---------- */
.provider-logos { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.provider { display: inline-flex; align-items: center; gap: 6px; }
.provider img, .provider-fallback { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; flex: none; }
.provider-logos.medium .provider img, .provider-logos.medium .provider-fallback { width: 34px; height: 34px; border-radius: 8px; }
.provider-logos.medium { gap: 10px 14px; }
.provider-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); font-size: .7rem; font-weight: 800; }
.provider-name { font-size: .85rem; }
.provider-line { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.rec-providers { min-height: 26px; margin-top: 6px; }
.platform-filter { display: flex; flex-direction: column; gap: 8px; margin: -4px 0 18px; }
.filter-label { font-weight: 700; font-size: .9rem; }
.platform-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.platform-chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none; height: 40px; padding: 0 12px 0 6px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.platform-chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.platform-chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.platform-chip.on::after { content: '✓'; color: var(--accent); font-weight: 800; }
.platform-chips .link.small { font-size: .85rem; flex: none; padding: 0 6px; }
.small-button { min-height: 36px; padding: 6px 14px; font-size: .9rem; }
.account-button {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 200px; height: 40px; padding: 2px 12px 2px 2px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}
.account-button:hover { border-color: var(--muted); }
.account-avatar { position: relative; display: inline-flex; flex: none; }
.account-name { min-width: 0; font-weight: 700; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-button.needs-username { border-color: var(--accent); }
.account-button.needs-username .account-name { color: var(--accent); }
.avatar {
  position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 800; flex: none;
}
.avatar.small { width: 36px; height: 36px; }
.avatar.large { width: 64px; height: 64px; font-size: 1.6rem; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sync-dot {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg); animation: pulse 1s infinite alternate;
}
@keyframes pulse { to { opacity: .35; } }
.account-card { max-width: 520px; margin: 0 auto; }
.benefits { padding-left: 1.2rem; margin: 1rem 0 1.4rem; }
.benefits li { margin-bottom: .4rem; }
.button.google { background: #fff; color: #1f1f1f; border-color: #dadce0; gap: 12px; width: 100%; max-width: 320px; }
.button.google:disabled { opacity: .6; cursor: wait; }
.profile { display: flex; align-items: center; gap: 16px; margin: 16px 0; }
.ok { color: #6fd08c; }

/* ---------- Privacidad y amigos ---------- */
.privacy .options { display: grid; gap: 8px; }
.option {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.option.selected { border-color: var(--accent); }
.option input { margin-top: 4px; accent-color: var(--accent); }
.option span { display: flex; flex-direction: column; }
.invite-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 16px; margin-bottom: 8px; }
.invite-card h2 { margin-top: 12px; }
.compat { font-size: 1.05rem; font-weight: 700; color: var(--accent); }
.their-score {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 34px; border-radius: 8px;
  background: hsl(var(--score-hue) 70% 50%); color: #111; font-weight: 800;
}
a.list-open { text-decoration: none; }
.profile h1 { margin: 0; }

/* ---------- Nombre de usuario ---------- */
.username-box { margin: 18px 0; padding: 4px 16px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.username-form { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.username-form .at { font-weight: 800; color: var(--muted); }
.username-form input {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.username-form .button:disabled, .review-editor .button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Estrenos ---------- */
.segmented { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.segmented button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 700; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.segmented button.on { background: var(--accent); color: var(--accent-text); }

/* ---------- Logros ---------- */
.achievements { margin-bottom: 8px; }
.level { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.level-icon { font-size: 2.4rem; line-height: 1; }
.level-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.level-text .progress { margin: 6px 0; max-width: none; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 12px 8px;
  border-radius: 12px; border: 1px dashed var(--border); background: var(--surface); opacity: .55; filter: grayscale(1);
}
.badge-card.earned { opacity: 1; filter: none; border-style: solid; border-color: var(--accent); }
.badge-icon { font-size: 1.8rem; }
.badge-card strong { font-size: .9rem; }

/* ---------- Reseñas ---------- */
.reviews-section { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 6px; }
.reviews { display: grid; gap: 10px; }
.review { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.review header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.review-author { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.review-author .avatar.small { width: 28px; height: 28px; font-size: .8rem; }
.review-movie { font-weight: 700; margin: 8px 0 0; }
.review-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 4px; }
.small-score { width: 32px; height: 28px; font-size: .9rem; }
.review-editor { margin: 10px 0 14px; }
.review-editor summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.review-editor textarea {
  width: 100%; margin-top: 8px; padding: 10px 12px; border-radius: 10px; resize: vertical;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}

main { padding-top: 24px; padding-bottom: 40px; min-height: 70vh; }
.intro { margin-bottom: 1.2rem; }

/* ---------- Botones ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--muted); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.ghost { background: transparent; }
.button.danger { color: var(--danger); }
.button.active { border-color: var(--accent); color: var(--accent); }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
.icon {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 1rem; cursor: pointer;
}
.icon:hover { border-color: var(--muted); }
.icon.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Progreso ---------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 12px 0; max-width: 420px; }
.progress-fill { height: 100%; background: var(--accent); transition: width .3s; }

/* ---------- Pósters ---------- */
.poster {
  position: relative; aspect-ratio: 2 / 3; overflow: hidden; border-radius: 10px;
  background: linear-gradient(150deg, hsl(var(--hue) 45% 32%), hsl(calc(var(--hue) + 60) 40% 16%));
  display: flex; align-items: flex-end;
}
.poster-fallback {
  padding: 10px; font-weight: 800; font-size: .95rem; line-height: 1.2;
  color: rgba(255,255,255,.92); text-shadow: 0 1px 6px rgba(0,0,0,.5);
}
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.poster.loaded img { opacity: 1; }
.poster.mini { width: 46px; flex: none; border-radius: 6px; }
.poster.mini .poster-fallback { font-size: 0; }
.poster.large { width: 100%; max-width: 300px; }
.poster.large .poster-fallback { font-size: 1.4rem; padding: 18px; }

/* ---------- Puntuar ---------- */
.rate-card {
  display: grid; grid-template-columns: minmax(160px, 300px) 1fr; gap: 28px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
}
.rate-body h2 { margin: 0; font-size: clamp(1.4rem, 3.5vw, 2rem); }
.question { font-weight: 700; margin-top: 1.2rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .8rem; }

.scale { display: flex; flex-direction: column; gap: 8px; }
.scale-buttons { display: flex; gap: 4px; flex-wrap: nowrap; }
.score-chip {
  --score-color: hsl(var(--score-hue) 70% 50%);
  flex: 1 1 0; min-width: 0; max-width: 46px; height: 44px; padding: 0;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  font: inherit; font-weight: 800; font-size: 1rem; cursor: pointer; transition: transform .1s, background .1s;
}
.score-chip.filled { background: color-mix(in srgb, var(--score-color) 28%, var(--surface-2)); color: var(--text); border-color: transparent; }
.score-chip.selected { background: var(--score-color); color: #111; transform: scale(1.08); }
.score-chip:hover { background: var(--score-color); color: #111; border-color: transparent; }
.scale-caption { font-size: .9rem; font-weight: 600; color: var(--muted); min-height: 1.4em; }
.scale.compact .scale-buttons { gap: 3px; }
.scale.compact .score-chip { width: 26px; flex: none; height: 30px; font-size: .78rem; border-radius: 7px; }

.search { margin-bottom: 20px; }
.search input, .settings input, select {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
.search-results { display: grid; gap: 6px; margin-top: 8px; }
.result, .list-open {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 8px; border-radius: 10px; border: 1px solid transparent;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.result:hover, .list-open:hover { border-color: var(--border); }
.result-text { display: flex; flex-direction: column; min-width: 0; }
.result-text strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; line-height: 1.3; }

.empty { text-align: center; padding: 48px 16px; }
.empty .progress { margin: 16px auto; }

/* ---------- Recomendaciones ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar select { width: auto; min-width: 200px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
.rec { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rec-open { position: relative; padding: 0; border: 0; background: none; cursor: pointer; }
.rec-open .poster { border-radius: 0; }
.match {
  position: absolute; top: 8px; right: 8px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: .8rem;
}
.rec-body { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; }
.rec-body h3 { margin: 0; font-size: .98rem; line-height: 1.25; }
.reason { font-size: .82rem; color: var(--text); opacity: .85; flex: 1; }
.rec-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- Mis películas ---------- */
.list { display: grid; gap: 6px; }
.list-row { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 10px; padding-right: 8px; }
.list-open { flex: 1; min-width: 0; }
.list-controls { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------- Ajustes ---------- */
.settings { display: grid; gap: 16px; max-width: 620px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.help { max-width: 720px; }
.help li { margin-bottom: .6rem; }

/* ---------- Ficha ---------- */
.details {
  width: min(860px, calc(100% - 24px)); max-height: calc(100% - 24px);
  padding: 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.details::backdrop { background: rgba(0,0,0,.7); }
.details .close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text); cursor: pointer; }
.details-head { display: grid; grid-template-columns: 200px 1fr; gap: 22px; }
.details-info h2 { margin: 0 32px 0 0; font-size: 1.6rem; }
.details-actions { margin-top: 14px; max-width: 560px; }
.scores { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 6px; }
.score { display: flex; flex-direction: column; min-width: 110px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); }
.score-value { font-size: 1.35rem; font-weight: 800; color: var(--accent); }
.score-source { font-weight: 700; font-size: .85rem; }
.score-extra { color: var(--muted); font-size: .75rem; }
.tagline { font-style: italic; color: var(--muted); }

/* ---------- Aviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 16px; align-items: center; width: max-content; max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 12px; background: #2b313d; border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast[hidden] { display: none; }

.footer { color: var(--muted); font-size: .8rem; padding-bottom: 32px; border-top: 1px solid var(--border); padding-top: 16px; }

@media (max-width: 640px) {
  .account-button { max-width: none; }
  .account-button .avatar.small { width: 32px; height: 32px; }
  .region-button { padding: 0 8px; }
  .region-button .region-code { display: none; }
  .brand { order: 1; }
  .topbar-end { order: 2; }
  .tabs { order: 3; flex-basis: 100%; }
  .rate-card { grid-template-columns: 1fr; padding: 16px; }
  .poster.large { max-width: 200px; margin: 0 auto; }
  .details { padding: 16px; }
  .details-head { grid-template-columns: 110px 1fr; gap: 14px; }
  .details-info h2 { font-size: 1.2rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  /* En el celular, las estrellas y la ✕ van en una segunda fila debajo del título. */
  .list-row { flex-wrap: wrap; gap: 0; padding: 0 8px 8px 0; }
  .list-open { flex: 1 1 100%; }
  .list-controls { flex: 1 1 100%; justify-content: space-between; padding-left: 66px; }
  .list-controls .scale { flex: 1; }
  .scale.compact .score-chip { width: auto; flex: 1 1 0; max-width: 34px; height: 34px; font-size: .85rem; }
  .list-row:not(:has(.scale)) { flex-wrap: nowrap; padding-bottom: 0; }
  .list-row:not(:has(.scale)) .list-open { flex: 1; }
  .list-row:not(:has(.scale)) .list-controls { flex: none; padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Instalar la app ---------- */
.install-banner {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 10px 12px;
  border-radius: var(--radius); border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.install-banner img { border-radius: 10px; flex: none; }
.install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.install-help { text-align: center; }
.install-help ol { text-align: left; max-width: 420px; margin: 12px auto; }
.install-help li { margin-bottom: 8px; }
.install-icon { border-radius: 16px; }
