:root {
  --bg: #0d0a14;
  --panel: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .14);
  --text: #f6f1ff;
  --muted: #a79fb8;
  --accent: #ff7a3d;
  --accent2: #ff3d8b;
  --gold: #ffc83d;
  --good: #3ddc84;
  --mid: #ffc83d;
  --bad: #ff5d6c;
  --grad: linear-gradient(135deg, #ff8a3d, #ff3d8b);
  --radius: 22px;
  --topbar: 56px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }
body {
  margin: 0; color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4; -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(120, 60, 200, .35), transparent 60%),
    radial-gradient(900px 560px at 100% 0%, rgba(255, 61, 139, .22), transparent 60%),
    radial-gradient(900px 600px at 50% 110%, rgba(255, 138, 61, .14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  position: relative; z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- шапка --- */
.topbar {
  height: var(--topbar); display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 20px;
  background: rgba(13, 10, 20, .55); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); position: relative; z-index: 2;
}
.brand { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-ico { filter: drop-shadow(0 0 8px rgba(255, 90, 90, .6)); }
.nav { display: flex; gap: 16px; align-items: center; font-size: 14px; }
.nav a { color: var(--text); opacity: .85; }
.nav a:hover { opacity: 1; text-decoration: none; }
.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.linklike:hover { color: var(--text); }

.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 56px; position: relative; }
.page-title { font-size: 26px; margin: 8px 0 20px; }
.muted { color: var(--muted); }

/* --- главная: всё на одном экране --- */
.page.fit {
  height: calc(100vh - var(--topbar));
  height: calc(100dvh - var(--topbar));
  padding: 14px 16px 14px;
}
.stage {
  height: 100%; display: grid; gap: 14px;
  grid-template-rows: minmax(0, 1fr) auto auto;
}

/* размытый постер как свечение на фоне */
.ambient {
  position: fixed; inset: -10%; width: 120%; height: 120%; object-fit: cover;
  filter: blur(70px) saturate(1.5); opacity: .38; z-index: -1; pointer-events: none;
}

/* --- карточка фильма --- */
.movie-card {
  justify-self: center; height: 100%; max-width: 100%; min-height: 220px; aspect-ratio: 9 / 14;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--radius); overflow: hidden;
  background: rgba(20, 14, 32, .8); border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6), 0 0 90px rgba(255, 61, 139, .2);
}
.movie-title {
  margin: 0; padding: 10px 16px; text-align: center; font-size: clamp(16px, 2.3vh, 22px);
  letter-spacing: .01em; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02));
}
.movie-photo { min-height: 0; position: relative; background: #0a0710; }
.movie-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.no-poster { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* --- блок оценок: ты | средняя | партнёр --- */
.rate-row {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center;
  width: min(100%, 1000px); margin: 0 auto;
}
.side {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 10px 14px 6px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  min-width: 0;
}
.side-me {
  border-color: rgba(255, 138, 61, .75);
  box-shadow: 0 0 0 1px rgba(255, 138, 61, .25), 0 10px 34px rgba(255, 80, 60, .16);
}
.side-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.side-name { font-weight: 700; }
.side-name small { color: var(--muted); font-weight: 500; margin-left: 6px; font-size: 12px; }
.side-score { font-size: 22px; font-weight: 800; }
.side-score i { font-size: 12px; font-style: normal; color: var(--muted); margin-left: 2px; }
.hint { margin: 2px 0 0; font-size: 12px; color: var(--muted); min-height: 1.4em; }

/* звёзды: в DOM идут 10..1, визуально 1..10 (row-reverse) — так работает подсветка при наведении */
.stars { display: flex; flex-direction: row-reverse; margin: 0; }
.star {
  flex: 1; min-width: 0; display: grid; justify-items: center;
  background: none; border: 0; padding: 2px 0; margin: 0; color: inherit; font: inherit; cursor: default;
}
.star-ico {
  font-size: clamp(22px, 3.6vh, 34px); line-height: 1.05; color: rgba(255, 255, 255, .17);
  transition: color .12s, transform .12s;
}
.star-num { font-size: 11px; color: var(--muted); }
.star.on .star-ico { color: var(--gold); text-shadow: 0 0 14px rgba(255, 200, 61, .5); }

.stars.interactive .star { cursor: pointer; }
.stars.interactive .star:hover .star-ico,
.stars.interactive .star:hover ~ .star .star-ico { color: #ffe08a; text-shadow: 0 0 14px rgba(255, 200, 61, .6); }
.stars.interactive .star:hover .star-ico { transform: scale(1.2); }
.star:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.star:disabled { opacity: 1; }

/* --- скрытая оценка партнёра --- */
.reveal-wrap { position: relative; }
.reveal-wrap.locked .stars { filter: blur(7px); opacity: .55; user-select: none; pointer-events: none; }
.lock-note {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 1px; padding: 0 10px;
}
.lock-note b { font-size: 15px; }
.lock-note span { font-size: 12.5px; color: #e4dcf3; }
.reveal-wrap.revealed .stars { animation: reveal .9s ease .6s both; }

@keyframes reveal {
  from { filter: blur(12px); opacity: .3; transform: scale(.97); }
  to   { filter: blur(0);    opacity: 1;  transform: none; }
}

/* --- средняя оценка --- */
.center-col { display: grid; justify-items: center; gap: 8px; min-width: 130px; }
.avg { text-align: center; display: grid; justify-items: center; line-height: 1.1; }
.avg-label { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.avg-num { font-size: clamp(38px, 6.4vh, 60px); font-weight: 900; letter-spacing: -.02em; }
.avg-sub { font-size: 12px; color: var(--muted); min-height: 1.2em; }
.avg.tone-good .avg-num { color: var(--good); text-shadow: 0 0 26px rgba(61, 220, 132, .5); }
.avg.tone-mid .avg-num { color: var(--mid); text-shadow: 0 0 26px rgba(255, 200, 61, .45); }
.avg.tone-bad .avg-num { color: var(--bad); text-shadow: 0 0 26px rgba(255, 93, 108, .5); }
.avg.locked .avg-num { color: rgba(255, 255, 255, .28); animation: pulse 2.2s ease-in-out infinite; }
.avg.revealed .avg-num { animation: pop .7s cubic-bezier(.2, 1.4, .4, 1) .75s both; }

@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

.btn {
  display: inline-block; background: var(--grad); color: #fff; border: 0; border-radius: 999px;
  padding: 12px 26px; font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 26px rgba(255, 61, 139, .35); transition: transform .12s, filter .12s;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); transform: translateY(-1px); }
.btn.small { padding: 7px 18px; font-size: 14px; }

/* --- Latest view --- */
.latest { display: grid; gap: 6px; justify-items: center; }
.latest-head { display: flex; justify-content: space-between; align-items: baseline; width: min(100%, 400px); }
.latest-head h2 { margin: 0; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.latest-head a { font-size: 13px; }
.latest-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: min(100%, 400px); }
.tile {
  position: relative; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); background: var(--panel);
  display: grid; place-items: center; color: var(--text); transition: transform .15s, border-color .15s;
}
a.tile:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-title { padding: 6px; font-size: 11px; text-align: center; }
.empty-tile { border-style: dashed; background: transparent; }
.tile-badge {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 4px; text-align: center;
  font-size: 11px; font-weight: 700; background: linear-gradient(0deg, rgba(0, 0, 0, .85), rgba(0, 0, 0, 0));
}

.empty { text-align: center; align-self: center; }
.empty-ico { font-size: 56px; }

/* --- история --- */
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.history-item {
  display: grid; grid-template-columns: 56px 1fr auto; grid-template-areas: "thumb title badge" "thumb scores badge";
  gap: 2px 14px; align-items: center; padding: 10px; color: var(--text);
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  backdrop-filter: blur(8px); transition: border-color .15s, transform .15s;
}
.history-item:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.thumb { grid-area: thumb; width: 56px; height: 76px; border-radius: 10px; overflow: hidden; background: #0a0710; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.h-title { grid-area: title; font-weight: 700; }
.h-scores { grid-area: scores; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.chip b { color: var(--text); }
.h-date { font-size: 12px; color: var(--muted); align-self: center; }
.rank { font-style: normal; color: var(--accent); font-weight: 800; margin-right: 6px; }

.history-wrap { max-width: 760px; margin: 0 auto; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.page-head .page-title { margin-bottom: 12px; }

/* кнопки сортировки */
.sortbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.sort-pill {
  padding: 7px 14px; border-radius: 999px; font-size: 14px; color: var(--text);
  border: 1px solid var(--line); background: var(--panel); transition: border-color .15s, transform .15s;
}
.sort-pill:hover { border-color: var(--accent); text-decoration: none; }
.sort-pill.on { background: var(--grad); border-color: transparent; font-weight: 700; box-shadow: 0 6px 20px rgba(255, 61, 139, .3); }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 0 0 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.dot-good { background: var(--good); }
.dot-mid  { background: var(--mid); }
.dot-bad  { background: var(--bad); }

/* кружок со средней оценкой: зелёный 7-10, жёлтый 4-6, красный ниже 4 */
.avg-badge {
  grid-area: badge; width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 16px; border: 2px solid var(--line);
}
.avg-badge.tone-good { color: var(--good); border-color: var(--good); background: rgba(61, 220, 132, .14); box-shadow: 0 0 18px rgba(61, 220, 132, .25); }
.avg-badge.tone-mid  { color: var(--mid);  border-color: var(--mid);  background: rgba(255, 200, 61, .13); box-shadow: 0 0 18px rgba(255, 200, 61, .22); }
.avg-badge.tone-bad  { color: var(--bad);  border-color: var(--bad);  background: rgba(255, 93, 108, .14); box-shadow: 0 0 18px rgba(255, 93, 108, .25); }
.avg-badge.locked { color: var(--muted); background: rgba(255, 255, 255, .04); font-size: 14px; }

/* --- вход --- */
.login {
  max-width: 380px; margin: 56px auto 0; padding: 28px 26px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  backdrop-filter: blur(14px); box-shadow: 0 24px 70px rgba(0, 0, 0, .5), 0 0 80px rgba(255, 61, 139, .15);
}
.login h1 { margin: 0 0 16px; font-size: 28px; }
.login-form { display: grid; gap: 14px; }
.login-form label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.login-form input {
  font: inherit; font-size: 16px; padding: 12px 14px; color: var(--text);
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: 12px;
}
.login-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.error { color: #ff8a7a; margin: 0; }

/* --- полоска автоперехода к следующему фильму --- */
.auto-next { display: grid; gap: 6px; justify-items: center; width: 130px; }
.auto-bar { position: relative; display: block; width: 100%; height: 4px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, .12); }
.auto-bar::after {
  content: ""; position: absolute; inset: 0; background: var(--grad); transform-origin: left;
  animation: autoFill var(--ms) linear forwards;
}
.auto-text { font-size: 12px; color: var(--muted); }
.auto-text a { margin-left: 6px; }
@keyframes autoFill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* --- плавное «выпрыгивание» блоков при загрузке ---
   fill-mode backwards: до старта блок скрыт, а после окончания возвращается к
   обычным стилям (поэтому hover-эффекты продолжают работать). */
@keyframes popIn {
  0%   { opacity: 0; transform: translateY(28px) scale(.9); }
  60%  { opacity: 1; transform: translateY(-4px) scale(1.02); }
  100% { opacity: 1; transform: none; }
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-100%); } }
@keyframes fadeIn { from { opacity: 0; } }

.topbar { animation: slideDown .5s cubic-bezier(.2, .8, .3, 1) backwards; }
.ambient { animation: fadeIn 1.2s ease backwards; }

.movie-card, .side, .center-col, .latest-head, .tile,
.page-head, .sortbar, .legend, .history li, .login, .empty {
  animation: popIn .6s cubic-bezier(.2, .8, .3, 1) backwards;
}

.movie-card   { animation-delay: .08s; }
.side-me      { animation-delay: .28s; }
.center-col   { animation-delay: .40s; }
.side-partner { animation-delay: .52s; }
.latest-head  { animation-delay: .66s; }
.latest-row > :nth-child(1) { animation-delay: .72s; }
.latest-row > :nth-child(2) { animation-delay: .80s; }
.latest-row > :nth-child(3) { animation-delay: .88s; }
.latest-row > :nth-child(4) { animation-delay: .96s; }
.latest-row > :nth-child(5) { animation-delay: 1.04s; }

.page-head { animation-delay: .06s; }
.sortbar   { animation-delay: .16s; }
.legend    { animation-delay: .24s; }
.history li { animation-delay: calc(.32s + min(var(--i, 0), 12) * .06s); }

.login, .empty { animation-delay: .1s; }

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

/* --- мобильный: всё те же блоки, но друг под другом --- */
@media (max-width: 760px) {
  :root { --topbar: 50px; }
  .topbar { padding: 0 14px; }
  .nav { gap: 12px; font-size: 13px; }
  .page.fit { padding: 10px 12px 12px; }
  .stage { gap: 10px; }
  .rate-row { grid-template-columns: 1fr; gap: 6px; }
  .side { padding: 6px 10px 4px; border-radius: 16px; }
  .side-score { font-size: 18px; }
  .star-ico { font-size: clamp(20px, 6.4vw, 30px); }
  .star-num { font-size: 10px; }
  .hint { display: none; }
  .center-col { grid-auto-flow: column; gap: 16px; justify-content: center; align-items: center; min-width: 0; }
  .avg { grid-auto-flow: column; gap: 10px; align-items: baseline; }
  .avg-label, .avg-sub { font-size: 11px; }
  .avg-num { font-size: 36px; }
  .latest-row { gap: 8px; }
  .tile { border-radius: 12px; }
  .lock-note b { font-size: 14px; }
  .lock-note span { font-size: 11.5px; }
}
