/* Manga Оцінки — блок оцінки тайтлу (engine/modules/mgrating) */
.mgr { display: flex; flex-direction: column; gap: 16px; }

/* Підсумок */
.mgr-summary { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 16px 18px; border-radius: 16px; background: linear-gradient(110deg, var(--accent-soft), transparent 75%); }
.mgr-total { display: flex; align-items: baseline; gap: 6px; }
.mgr-total__val { font-family: var(--font-head); font-size: 46px; font-weight: 800; line-height: 1; color: var(--hot); }
.mgr-total__of { font-size: 16px; font-weight: 600; color: var(--muted); }
.mgr-summary__meta { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.mgr-summary__meta b { font-size: 15px; color: var(--text); }
.mgr-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.mgr-top > .mgr-summary:only-child { grid-column: 1 / -1; }
.mgr-raw { font-size: 12px; cursor: help; border-bottom: 1px dotted var(--line); align-self: flex-start; }

/* Розподіл оцінок 1–10 */
.mgr-dist { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 12px 16px; border-radius: 16px; background: var(--surface); }
.mgr-dist__row { display: grid; grid-template-columns: 18px minmax(0, 1fr) 44px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.mgr-dist__n { font-weight: 700; text-align: right; color: var(--text); }
.mgr-dist__bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.mgr-dist__bar span { display: block; height: 100%; min-width: 0; border-radius: 4px; background: var(--hot); transition: width .4s ease; }
.mgr-dist__c { text-align: right; font-variant-numeric: tabular-nums; }
.mgr-log-btn { align-self: flex-start; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }

/* Швидка оцінка */
.mgr-quick { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.mgr-quick__btns { display: flex; gap: 4px; flex-wrap: wrap; }
.mgr-quick__btn { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: var(--radius-btn); background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.mgr-quick__btn:hover { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

/* Критерії */
.mgr-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.mgr-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--surface); }
.mgr-row__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mgr-row__label { font-weight: 700; font-size: 14px; }
.mgr-row__avg { font-family: var(--font-head); font-size: 16px; font-weight: 700; color: var(--hot); }
.mgr-row__bar { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.mgr-row__bar span { display: block; height: 100%; background: var(--hot); border-radius: 4px; transition: width .4s ease; }
.mgr-row__picks { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.mgr-pick { height: 30px; padding: 0; border: 0; border-radius: 6px; background: var(--surface-2); color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; transition: background .1s, color .1s; }
.mgr-pick:disabled { cursor: default; }
.mgr-pick.is-on { background: var(--accent); color: var(--accent-ink); }
.mgr-pick.is-hover { background: var(--accent-soft); color: var(--text); }
.mgr-row[data-value="0"] .mgr-pick.is-hover:last-of-type { background: var(--accent-soft); }

/* Збереження */
.mgr-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mgr-save { min-height: 46px; padding: 0 22px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 10px 22px -12px var(--accent); }
.mgr-save:disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.mgr-save.is-busy { opacity: .6; pointer-events: none; }
.mgr-hint { font-size: 13px; color: var(--muted); }
.mgr-hint.is-ok { color: var(--ok); }
.mgr-hint.is-error { color: var(--danger); }
.mgr-hint--lock { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: var(--surface); color: var(--text); }
.mgr-hint--lock::before { content: "🔒"; font-size: 14px; }
.mgr[data-state="closed"] .mgr-pick, .mgr-pick:disabled { opacity: .75; }

/* Історія оцінок */
.mgr-dialog { width: min(640px, calc(100vw - 32px)); max-height: min(80vh, 720px); padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.mgr-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.mgr-dialog__head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.mgr-dialog__head h2 { margin: 0; font-family: var(--font-head); font-size: 17px; }
.mgr-dialog__close { width: 36px; height: 36px; border: 0; border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: 20px; cursor: pointer; }
.mgr-log { list-style: none; margin: 0; padding: 8px 18px; }
.mgr-log li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.mgr-log__top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.mgr-log__name { font-weight: 700; }
.mgr-log__group { margin-left: 6px; font-size: 12px; color: var(--muted); }
.mgr-log__avg { font-family: var(--font-head); font-weight: 700; color: var(--hot); }
.mgr-log__vals { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.mgr-log__more { display: block; width: calc(100% - 36px); margin: 8px 18px 18px; min-height: 42px; border: 0; border-radius: var(--radius-btn); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }

@media (max-width: 760px) {
  .mgr-top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .mgr-rows { grid-template-columns: minmax(0, 1fr); }
  .mgr-total__val { font-size: 38px; }
  .mgr-quick__btn { width: 30px; height: 30px; }
}

/* ═══ Компактно: підсумок + міні-гістограма; критерії — плашки, вибір балів — за кнопкою ═══ */
.mgr { gap: 12px; }
.mgr-top { grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 10px; }
.mgr-summary { gap: 16px; padding: 12px 16px; border-radius: 14px; background: var(--surface); }
.mgr-total__val { font-size: 36px; }
.mgr-total__of { font-size: 14px; }
.mgr-summary__meta { gap: 1px; }
.mgr-summary__links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 4px; }
.mgr-summary__links .mgr-log-btn { margin: 0; color: var(--muted); }
.mgr-summary__links .mgr-log-btn:hover { color: var(--text); }
.mgr-open { margin-left: auto; align-self: center; min-height: 38px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.mgr-open:hover { filter: brightness(1.1); }
.mgr.is-open .mgr-open { background: var(--surface-2); color: var(--text); }

/* Розподіл — 10 стовпчиків */
.mgr-dist.mgr-dist--cols { flex-direction: row-reverse; justify-content: stretch; align-items: stretch; gap: 4px; padding: 10px 12px 8px; border-radius: 14px; }
.mgr-dist--cols .mgr-dist__row { flex: 1 1 0; display: flex; flex-direction: column-reverse; align-items: center; gap: 3px; min-width: 0; }
.mgr-dist--cols .mgr-dist__n { text-align: center; font-size: 11px; color: var(--muted); }
.mgr-dist--cols .mgr-dist__c { text-align: center; font-size: 10px; line-height: 1; min-height: 10px; }
.mgr-dist--cols .mgr-dist__bar { display: flex; align-items: flex-end; width: 100%; max-width: 18px; height: 46px; border-radius: 4px; }
.mgr-dist--cols .mgr-dist__bar span { width: 100%; border-radius: 4px; transition: height .4s ease; }
.mgr-dist--cols .mgr-dist__row:hover .mgr-dist__n { color: var(--text); }

/* Критерії згорнуто: компактні плашки із середнім балом */
.mgr:not(.is-open) .mgr-rows { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.mgr:not(.is-open) .mgr-row { gap: 6px; padding: 9px 12px; border-radius: 10px; }
.mgr:not(.is-open) .mgr-row__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.mgr:not(.is-open) .mgr-row__avg { font-size: 15px; }
.mgr:not(.is-open) .mgr-row__bar { height: 3px; }
.mgr:not(.is-open) .mgr-row__picks,
.mgr:not(.is-open) .mgr-foot:not(:has(.mgr-hint--lock)) { display: none; }
.mgr.is-open .mgr-rows { animation: pop-in var(--t, .38s) var(--ease, ease) both; }
.mgr-hint--lock { padding: 8px 12px; font-size: 13px; color: var(--muted); background: none; }

@media (max-width: 760px) {
  .mgr-top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .mgr-total__val { font-size: 32px; }
  .mgr-open { width: 100%; margin-left: 0; }
  .mgr:not(.is-open) .mgr-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.mgr:not(.is-open) .mgr-rows { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
@media (max-width: 560px) { .mgr:not(.is-open) .mgr-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Без розподілу оцінок — підсумок на всю ширину; розгорнуто — підказка над критеріями */
.mgr-top { grid-template-columns: minmax(0, 1fr); }
.mgr-dist { display: none; }
.mgr.is-open .mgr-rows { scroll-margin-top: 90px; }
.mgr.is-open .mgr-rows::before { content: "Оцініть кожен критерій від 1 до 10, потім збережіть оцінку."; grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.mgr.is-open .mgr-foot { padding-top: 2px; }
.mgr.is-open .mgr-rows { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .mgr.is-open .mgr-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .mgr.is-open .mgr-rows { grid-template-columns: minmax(0, 1fr); } }

/* Швидка оцінка — лише у відкритому оцінюванні (раніше висіла над згорнутими критеріями) */
.mgr:not(.is-open) .mgr-quick { display: none; }
.mgr.is-open .mgr-quick { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); animation: pop-in var(--t, .38s) var(--ease, ease) both; }
.mgr.is-open .mgr-quick__label { font-weight: 600; color: var(--text); }
