:root {
    --bg: #110a0b;
    --bg-2: #1a1012;
    --card: #221416;
    --line: #3b2327;
    --text: #f7eded;
    --muted: #b39a9d;
    --accent: #c91c2d;      /* основной цвет */
    --accent-mid: #e33747;  /* вторая точка градиента на кнопках (белый текст читается) */
    --accent-2: #ff5a68;    /* светлый красный: текст и обводки на тёмном фоне */
    --ok: #3ddc97;
    --bad: #ff6b7a;
    --radius: 16px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --display: "Unbounded", var(--font);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background:
        radial-gradient(900px 500px at 85% -10%, rgba(201, 28, 45, .22), transparent 60%),
        radial-gradient(700px 400px at -10% 10%, rgba(255, 90, 104, .08), transparent 60%),
        var(--bg);
    color: var(--text);
    font: 15px/1.55 var(--font);
    min-height: 100vh;
}

a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- шапка ---------- */

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1320px;
    margin: 0 auto;
    padding: 18px 20px;
}

.logo {
    font: 700 20px/1 var(--display);
    text-decoration: none;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

main { max-width: 1320px; margin: 0 auto; padding: 0 20px 40px; }

/* ---------- верх: текст + форма ---------- */

.hero {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 32px;
    align-items: start;
    padding: 28px 0 32px;
}

h1 {
    font: 700 clamp(30px, 4.6vw, 54px)/1.08 var(--display);
    margin: 0 0 16px;
    letter-spacing: -.01em;
}

.hero p { color: var(--muted); max-width: 520px; margin: 0 0 12px; font-size: 16px; }
.hero .counter { color: var(--text); font-weight: 600; }

.rating {
    background: linear-gradient(180deg, rgba(201, 28, 45, .12), transparent 40%), var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 22px;
}

.rating-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.rating-head h2 { font: 600 18px/1.2 var(--display); margin: 0; }
.rating-sub { font-size: 13px; color: var(--muted); }

.rating-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rating-list li { margin: 0; }
.rating-row {
    width: 100%;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.rating-row:hover { background: var(--bg-2); }
.rating-row.active { border-color: var(--accent); background: var(--bg-2); }

.place {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid; place-items: center;
    font: 700 13px/1 var(--display);
    background: var(--bg-2);
    color: var(--muted);
}
.place.p1 { background: linear-gradient(135deg, #ffd76a, #e8a93a); color: #3a2600; }
.place.p2 { background: linear-gradient(135deg, #e4e7ef, #a9b0c2); color: #262a35; }
.place.p3 { background: linear-gradient(135deg, #f0b48a, #b8734a); color: #3b1e0b; }

.who { display: grid; gap: 5px; min-width: 0; }
.who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 5px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.score { font-weight: 600; font-variant-numeric: tabular-nums; }
.score small { color: var(--muted); font-weight: 400; margin-left: 4px; }

.rating-empty { color: var(--muted); margin: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--text);
    border-radius: 12px;
    padding: 11px 16px;
    font: 600 14px/1 var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: transform .1s, background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-mid)); border: 0; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; }

/* ---------- авторы и фильтр ---------- */

.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; color: var(--muted); }
.filter-bar b { color: var(--text); }

/* ---------- сетка ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }

.card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--card);
    cursor: zoom-in;
    border: 0;
    padding: 0;
    aspect-ratio: var(--ratio, 1);
    animation: appear .35s ease both;
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s; }
.card:hover img { transform: scale(1.04); }
.card .cap {
    position: absolute;
    inset: auto 0 0 0;
    padding: 28px 12px 10px;
    background: linear-gradient(transparent, rgba(10, 5, 6, .85));
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 8px;
    color: #fff;
    font-size: 13px;
    text-align: left;
}
.card .cap b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .cap small { color: rgba(255, 255, 255, .7); flex: none; }
.badge {
    position: absolute;
    top: 10px; left: 10px;
    font: 600 11px/1 var(--font);
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(10, 5, 6, .7);
    backdrop-filter: blur(6px);
    color: #fff;
}
@keyframes appear { from { opacity: 0; transform: translateY(6px); } }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.sentinel { height: 1px; }

/* ---------- просмотр ---------- */

.viewer {
    width: min(1200px, 100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--bg-2);
    color: var(--text);
    overflow: hidden;
}
.viewer::backdrop { background: rgba(8, 3, 4, .85); backdrop-filter: blur(4px); }

.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; max-height: calc(100vh - 26px); }
.viewer-img { background: #0a0506; display: grid; place-items: center; min-height: 0; }
.viewer-img img { max-width: 100%; max-height: calc(100vh - 26px); display: block; object-fit: contain; }

.viewer-info { padding: 24px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.v-nick { font: 600 20px/1.2 var(--display); text-decoration: none; word-break: break-word; }
.v-nick:hover { color: var(--accent-2); }
.v-meta { color: var(--muted); font-size: 13px; }
.prompt-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.prompt-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.prompt-box p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.prompt-box p.none { color: var(--muted); font-style: italic; }
.v-actions { display: grid; gap: 8px; }

.viewer .close, .viewer .nav {
    position: absolute;
    z-index: 2;
    border: 0;
    background: rgba(10, 5, 6, .6);
    color: #fff;
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(6px);
}
.viewer .close { top: 12px; right: 12px; }
.viewer .nav { top: 50%; transform: translateY(-50%); font-size: 28px; line-height: 1; }
.viewer .prev { left: 12px; }
.viewer .next { right: 352px; }

.toast {
    position: fixed;
    left: 50%; bottom: 24px;
    transform: translate(-50%, 20px);
    background: var(--text);
    color: var(--bg);
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 20px 40px; }

/* ---------- телефоны ---------- */

@media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 12px; }
    .viewer-body { grid-template-columns: 1fr; overflow-y: auto; }
    .viewer-img img { max-height: 70vh; }
    .viewer .next { right: 12px; }
    .viewer .nav { top: 35vh; }
}

@media (max-width: 560px) {
    main, .top { padding-left: 16px; padding-right: 16px; }
    .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .card .cap small { display: none; }
    .rating { padding: 16px; }
}

/* Кольцо фокуса — только при навигации с клавиатуры */
.viewer button:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
