/* ============ KogaImaVise — mobile-first, dark ============ */
:root {
    --bg: #0e0f13;
    --card: #181a22;
    --card-2: #1f222d;
    --text: #f2f3f7;
    --muted: #8b90a0;
    --line: #262a36;
    --a: #ff4d5a;      /* opcija A — crvena */
    --a-soft: rgba(255, 77, 90, .22);
    --b: #3d8bff;      /* opcija B — plava */
    --b-soft: rgba(61, 139, 255, .22);
    --radius: 18px;
}

* { box-sizing: border-box; }

/* hidden mora da pobedi display iz klasa (npr. flex/grid) */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.4;
    overflow-x: hidden;
}

button { font: inherit; color: inherit; }

/* ---------- header ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 560px;
    margin: 0 auto;
    padding: 14px 16px 10px;
    background: rgba(14, 15, 19, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: .06em;
    color: var(--text);
    text-decoration: none;
}

.brand-accent { color: var(--a); }

.topbar-auth {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .85rem;
}

.me { color: var(--muted); font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link-btn {
    background: none;
    border: 0;
    padding: 0;
    color: var(--b);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    text-decoration: none;
}

/* ---------- shell ---------- */
.shell {
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 12px 80px;
}

/* ---------- category chips ---------- */
.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.chip--active {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

/* ---------- duel card ---------- */
.duel-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.duel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px 10px;
}

.duel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.icon-btn {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--card-2);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.duel-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px 12px;
    color: var(--muted);
    font-size: .82rem;
}

.comment-link {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    padding: 4px 2px;
}
.comment-link:hover { color: var(--text); }

/* ---------- split layout (sa slikama) ---------- */
.split {
    position: relative;
    display: flex;
    aspect-ratio: 16 / 11;
}

.side {
    position: relative;
    flex: 1;
    border: 0;
    padding: 0;
    background-color: var(--card-2);
    background-size: cover;
    background-position: center;
    cursor: pointer;
    overflow: hidden;
}

.side::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.65), rgba(0,0,0,.05) 45%);
    transition: background-color .3s;
}

.voted .side::after { background-color: rgba(0, 0, 0, .35); }

.side-name {
    position: absolute;
    left: 0; right: 0; bottom: 10px;
    z-index: 3;
    font-weight: 800;
    font-size: .95rem;
    text-shadow: 0 1px 6px rgba(0,0,0,.8);
    padding: 0 6px;
}

.vs-badge {
    position: absolute;
    left: 50%; top: 50%;
    z-index: 4;
    transform: translate(-50%, -50%);
    width: 44px; height: 44px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--line);
    font-weight: 900;
    font-size: .8rem;
    letter-spacing: .04em;
    pointer-events: none;
}

.bar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 2;
    height: 0%;
    transition: height .9s cubic-bezier(.22, 1, .36, 1);
    pointer-events: none;
}

.bar--a { background: linear-gradient(to top, var(--a), var(--a-soft)); opacity: .82; }
.bar--b { background: linear-gradient(to top, var(--b), var(--b-soft)); opacity: .82; }

.pct {
    position: absolute;
    left: 0; right: 0;
    top: 34%;
    z-index: 3;
    font-size: 1.7rem;
    font-weight: 900;
    text-shadow: 0 2px 10px rgba(0,0,0,.9);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .5s .3s, transform .5s .3s;
    pointer-events: none;
}

.voted .pct { opacity: 1; transform: none; }

.voted .side { cursor: default; }

.side--mine { outline: 3px solid rgba(255,255,255,.85); outline-offset: -3px; z-index: 1; }

/* ---------- tug-of-war layout ---------- */
.tug { padding: 6px 14px 4px; }

.tug-teams {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-weight: 800;
    font-size: .95rem;
}

.tug-team--a { color: var(--a); }
.tug-team--b { color: var(--b); text-align: right; }

.rope { position: relative; height: 54px; }

.rope-line {
    position: absolute;
    left: 2px; right: 2px; top: 50%;
    height: 6px;
    transform: translateY(-50%);
    border-radius: 3px;
    background: linear-gradient(90deg, var(--a) 0%, var(--a-soft) 42%, var(--line) 50%, var(--b-soft) 58%, var(--b) 100%);
}

.rope-center {
    position: absolute;
    left: 50%; top: 8px; bottom: 8px;
    width: 0;
    border-left: 2px dashed rgba(139, 144, 160, .45);
    transform: translateX(-50%);
}

.knot {
    position: absolute;
    left: 50%; top: 50%;
    width: 26px; height: 26px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff, #c8ccd8 65%, #9aa0b0);
    box-shadow: 0 2px 10px rgba(0,0,0,.55);
    transition: left .9s cubic-bezier(.22, 1, .36, 1);
}

.tug-actions { display: flex; gap: 10px; padding: 4px 0 10px; }

.tug-btn {
    position: relative;
    flex: 1;
    padding: 12px 8px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--card-2);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    transition: transform .1s, border-color .2s;
    overflow: hidden;
}

.tug-btn:active { transform: scale(.97); }

.tug-btn--a:hover { border-color: var(--a); }
.tug-btn--b:hover { border-color: var(--b); }

.voted .tug-btn { cursor: default; }
.voted .tug-btn-label { display: none; }

.tug-btn-result { display: none; font-weight: 800; }
.voted .tug-btn-result { display: block; }
.tug-btn-result--a { color: var(--a); }
.tug-btn-result--b { color: var(--b); }

.voted .tug-btn--mine.tug-btn--a { border-color: var(--a); background: var(--a-soft); }
.voted .tug-btn--mine.tug-btn--b { border-color: var(--b); background: var(--b-soft); }

/* ---------- feed misc ---------- */
.feed-empty, .feed-loader {
    text-align: center;
    color: var(--muted);
    padding: 32px 0;
}

#feed-sentinel { height: 1px; }

.single-duel { padding-top: 8px; }

.more-link {
    display: block;
    text-align: center;
    margin-top: 18px;
    padding: 13px;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

/* ---------- toast ---------- */
.toast {
    position: fixed;
    left: 50%; bottom: 26px;
    transform: translateX(-50%);
    z-index: 50;
    max-width: 90vw;
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--text);
    color: var(--bg);
    font-size: .88rem;
    font-weight: 600;
    box-shadow: 0 6px 24px rgba(0,0,0,.5);
    animation: toast-in .25s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- error page (template) ---------- */
.error-page { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- buttons ---------- */
.btn-primary {
    display: inline-block;
    width: 100%;
    padding: 13px;
    border: 0;
    border-radius: 12px;
    background: var(--a);
    color: #fff;
    font-weight: 800;
    font-size: .95rem;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary:active { transform: scale(.99); }

.btn-ghost {
    width: 100%;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
}

/* ---------- auth (prijava) ---------- */
.auth-card {
    max-width: 380px;
    margin: 24px auto;
    padding: 24px 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.auth-title { margin: 0 0 4px; font-size: 1.4rem; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: .9rem; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.auth-label { font-size: .82rem; color: var(--muted); font-weight: 600; }

.auth-form input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card-2);
    color: var(--text);
    font-size: 1rem;
}

#code { letter-spacing: 6px; font-weight: 700; text-align: center; }

.auth-select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card-2);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

.auth-form input:focus, .auth-select:focus { outline: 2px solid var(--b); border-color: var(--b); }

.flash-ok {
    background: rgba(47, 191, 113, .15);
    border: 1px solid #2fbf71;
    color: #2fbf71;
    padding: 12px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 16px;
}

.suggest-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--card);
    border: 1px dashed var(--line);
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 16px;
    text-decoration: none;
    color: var(--text);
}
.suggest-cta b { font-size: .95rem; }
.suggest-cta span { color: var(--muted); font-size: .8rem; }
.suggest-cta .cta-arrow { color: var(--a); font-weight: 800; font-size: 1.2rem; }

.auth-msg { margin: 14px 0 0; font-size: .88rem; color: var(--muted); min-height: 1.2em; }
.auth-msg--error { color: var(--a); }

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 2px;
}
.auth-links .link-btn:disabled { color: var(--muted); cursor: default; }

/* ---------- comments (Instagram-stil) ---------- */
.comments { margin-top: 22px; }
.comments-title { font-size: 1.05rem; margin: 0 0 6px; }

.locked {
    text-align: center;
    padding: 26px 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.locked-icon { font-size: 1.8rem; }
.locked p { color: var(--muted); margin: 8px 0 16px; }
.locked .btn-primary { max-width: 260px; }

.thread-empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* avatar krug sa inicijalom */
.avatar {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
    line-height: 1;
    user-select: none;
}
.avatar--sm { width: 30px; height: 30px; font-size: .82rem; }

/* jedan komentar — bez okvira, čист red */
.comment-thread { display: flex; flex-direction: column; }
.comment { padding: 8px 0; }
.comment-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 11px; align-items: start; }
.comment-body { min-width: 0; }
.comment-line { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.comment-author { font-weight: 600; font-size: .88rem; }
.comment-time { color: var(--muted); font-size: .75rem; }
.comment-text { margin: 2px 0 0; font-size: .92rem; line-height: 1.35; white-space: pre-wrap; word-break: break-word; }

.comment-meta { margin-top: 5px; }
.reply-btn {
    background: none; border: 0; padding: 0;
    color: var(--muted); font-size: .76rem; font-weight: 600; cursor: pointer;
}
.reply-btn:hover { color: var(--text); }

/* srce sa desne strane, vertikalno */
.like-btn {
    flex: 0 0 auto;
    min-width: 24px;
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    background: none; border: 0; padding: 2px 0;
    color: var(--text); cursor: pointer;
    align-self: flex-start;
}
.like-heart { font-size: 1.2rem; line-height: 1; transition: transform .12s; }
.like-btn:active .like-heart { transform: scale(1.25); }
.like-count { font-size: .72rem; color: var(--muted); }
.like-btn.liked { color: var(--a); }
.like-btn.liked .like-count { color: var(--a); }

/* odgovori — uvučeni, manji avatar, bez debelog okvira */
.replies { margin-left: 45px; }
.replies:empty { display: none; }
.replies .avatar { width: 28px; height: 28px; font-size: .78rem; }
.replies .comment-row { gap: 9px; }

/* composer (Instagram bottom bar) — sedi na dnu sheet panela */
.composer {
    flex: 0 0 auto;
    background: var(--card);
    padding: 4px 14px 6px;
    border-top: 1px solid var(--line);
}
.reply-hint {
    font-size: .8rem;
    color: var(--muted);
    padding: 6px 4px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.emoji-row {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    padding: 6px 2px;
    overflow-x: auto;
    scrollbar-width: none;
}
.emoji-row::-webkit-scrollbar { display: none; }
.emoji {
    flex: 0 0 auto;
    background: none; border: 0;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 2px 4px;
    opacity: .9;
}
.emoji:hover { transform: scale(1.15); }
.composer-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 2px 12px;
}
.composer-bar textarea {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
    resize: none;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: .95rem;
    font-family: inherit;
    line-height: 1.35;
    max-height: 120px;
    padding: 6px 0;
}
.composer-bar textarea:focus { outline: none; }
.send-btn {
    flex: 0 0 auto;
    background: none; border: 0;
    color: var(--b);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    padding: 4px 2px;
}
.send-btn:hover { color: var(--text); }

.single-duel { padding-top: 8px; }

/* ---------- comment sheet (klizni panel odozdo) ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet[hidden] { display: none; }

.sheet-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, .6);
    opacity: 0;
    transition: opacity .26s ease;
}
.sheet.open .sheet-backdrop { opacity: 1; }

.sheet-panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.22, 1, .36, 1);
    will-change: transform;
}
.sheet.open .sheet-panel { transform: none; }

.sheet-handle {
    width: 40px; height: 4px;
    margin: 9px auto 2px;
    border: 0; padding: 0;
    border-radius: 2px;
    background: var(--line);
    cursor: pointer;
}
.sheet-head {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 6px 14px 10px;
    border-bottom: 1px solid var(--line);
}
.sheet-title { margin: 0; font-size: 1rem; font-weight: 700; }
.sheet-close {
    position: absolute; right: 12px; top: 50%;
    transform: translateY(-50%);
    background: none; border: 0;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
}
.sheet-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 6px 14px 8px;
    -webkit-overflow-scrolling: touch;
}
.sheet-body .locked { border: 0; background: none; }

body.sheet-lock { overflow: hidden; }

/* na desktopu — centriran dijalog umesto pune širine */
@media (min-width: 700px) {
    .sheet-panel {
        left: 50%; right: auto; bottom: auto; top: 50%;
        width: 480px;
        max-height: 80vh;
        border-radius: 18px;
        transform: translate(-50%, -48%) scale(.98);
        opacity: 0;
        transition: transform .24s ease, opacity .24s ease;
    }
    .sheet.open .sheet-panel { transform: translate(-50%, -50%); opacity: 1; }
    .sheet-handle { display: none; }
}

/* ---------- desktop ---------- */
@media (min-width: 700px) {
    .shell { padding-top: 20px; }
    .duel-title { font-size: 1.08rem; }
}
