:root {
    --bg: #0f172a;
    --card: #111827;
    --muted: #94a3b8;
    --text: #e5e7eb;
    --brand: #4f46e5;
    --link: #7dd3fc;
    --link-hover: #a5b4fc;
    --scroll-track: rgba(148,163,184,.08);
    --scroll-thumb: rgba(79,70,229,.65);
    --scroll-thumb-hover: rgba(79,70,229,.9);
    --card-bg: #0b1220
}

html, body {
    height: 100%
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: linear-gradient(120deg,#06070a,#0a0d14);
    font-family: system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
    color: var(--text)
}

.wrap {
    max-width: 1200px;
    margin: 32px auto;
    padding: 0 16px
}

.card {
    background: rgb(12 20 37 / 52%);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(148,163,184,.2);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 16px
}

h1 {
    margin: 0 0 14px
}

p.muted {
    color: var(--muted);
    margin: 8px 0 18px;
    font-size: 12px
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr
}

.row {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr;
    align-items: start
}

    .row > div {
        min-width: 0
    }

label {
    font-size: 14px;
    color: #cbd5e1
}

input, textarea, select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148,163,184,.35);
    background: #0b1220;
    color: var(--text);
    margin: 10px 0
}

textarea {
    min-height: 160px;
    resize: vertical;
    display: block
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap
}

button {
    cursor: pointer;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    color: #fff;
    background: var(--brand);
    font-weight: 600
}

    button.ghost {
        background: transparent;
        border: 1px solid rgba(148,163,184,.35)
    }

    button.mini {
        background: #0b1220;
        border: 1px solid rgba(148,163,184,.35);
        color: #cbd5e1;
        padding: 4px 8px;
        border-radius: 10px;
        font-size: 12px
    }

    button:disabled {
        opacity: .5;
        cursor: not-allowed
    }

.hint {
    font-size: 12px;
    color: #9ca3af
}

.progress {
    height: 10px;
    background: #0b1220;
    border: 1px solid rgba(148,163,184,.3);
    border-radius: 999px;
    overflow: hidden
}

.bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg,#22d3ee,#4f46e5);
    transition: width .3s ease
}

/* ========== PC 테이블 ========== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    table-layout: fixed
}

    .table th, .table td {
        border-bottom: 1px solid rgba(148,163,184,.2);
        padding: 10px 8px;
        text-align: left;
        font-size: 14px;
        vertical-align: top;
        word-break: keep-all
    }

    .table th {
        color: #cbd5e1;
        white-space: nowrap
    }

.narrow {
    width: 52px
}

.code {
    display: inline-block;
    max-width: 260px;
    font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
    font-size: 12px;
    background: #0b1220;
    border: 1px solid rgba(148,163,184,.25);
    padding: 6px 8px;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid rgba(148,163,184,.35)
}

.ok {
    background: #052e1a;
    border-color: #16a34a;
    color: #a7f3d0
}

.warn {
    background: #2a1a05;
    border-color: #f59e0b;
    color: #fde68a
}

.fail {
    background: #3b0d0d;
    border-color: #ef4444;
    color: #fecaca
}

.win {
    outline: 1px dashed #22d3ee;
    outline-offset: 2px;
    border-radius: 6px;
    padding: 0 6px
}

a {
    color: var(--link);
    text-decoration: none
}

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

    a:visited {
        color: var(--link)
    }

/* 상위 노출 칩 */
.topwrap {
    display: flex;
    gap: 6px;
    flex-wrap: wrap
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(148,163,184,.35);
    background: #0b1220;
    color: #e5e7eb;
    font-size: 12px;
    max-width: 170px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

    .chip .num {
        display: inline-grid;
        place-items: center;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        border: 1px solid rgba(148,163,184,.35);
        font-size: 10px;
        background: rgba(148,163,184,.12)
    }

/* ========== 모바일 카드 ========== */
.cards {
    display: none;
    margin-top: 16px
}

.mcard {
    border: 1px solid rgba(148,163,184,.2);
    border-radius: 16px;
    padding: 12px;
    background: #0b1220;
    margin-bottom: 10px
}

.m-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center
}

.m-key {
    font-weight: 700
}

.m-ranks {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 8px 0
}

.m-url {
    margin-top: 6px
}

    .m-url .code {
        max-width: 100%
    }

.m-top {
    margin-top: 8px
}

/* 반응형 */
@media (max-width:980px) {
    .row {
        grid-template-columns: 1fr
    }
}

@media (max-width:640px) {
    .wrap {
        margin: 20px auto
    }

    .card {
        padding: 14px
    }

    .table-wrap.rank-table-wrap {
        display: none
    }
    /* PC용 결과표 숨김 */
    .cards {
        display: block
    }

    .logo_top img {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 50%
    }
}

.small {
    font-size: 12px;
    color: #9ca3af
}

.logo_top {
    display: flex;
    flex-direction: column;
    align-items: center
}

.logo_p {
    font-size: 13px;
    letter-spacing: -1px;
    margin-top: -1px;
    color: #ffffff9c;
    margin-bottom: 30px
}

/* 팝업 */
#popupOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.5);
    z-index: 999
}

#popupBox {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    background: #ffffff0d;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    max-width: 90%;
    box-shadow: 0 0 15px rgba(0,0,0,.3)
}

    #popupBox img {
        max-width: 100%;
        height: auto;
        display: block;
        margin-bottom: 10px
    }

.popupBtn {
    margin: 5px;
    padding: 6px 12px;
    background-color: #007BFF;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer
}

    .popupBtn:hover {
        background-color: #0056b3
    }

@media (max-width:640px) {
    #popupBox {
        width: 90%
    }
}

/* 가운데만 블러 처리용 */
.maskWrap {
    display: inline-flex;
    gap: 2px;
    align-items: baseline;
    max-width: 100%;
    overflow: hidden
}

.maskLeft, .maskRight {
    opacity: .95
}

.maskMid {
    filter: blur(4px);
    display: inline-block;
    user-select: none;
    pointer-events: none;
    padding: 0 .1em
}

/* ===== 실시간 이용 현황 (카드 내부 스크롤 + 가로 스크롤 차단) ===== */
.activity-table-wrap {
    overflow-x: hidden !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    max-height: 260px
}

#activityTbl {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse
}

    #activityTbl th, #activityTbl td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 1px
    }

        #activityTbl th:nth-child(1), #activityTbl td:nth-child(1) {
            width: 48%
        }
        /* 사이트 */
        #activityTbl th:nth-child(2), #activityTbl td:nth-child(2) {
            width: 37%
        }
        /* 키워드 */
        #activityTbl th:nth-child(3), #activityTbl td:nth-child(3) {
            width: 15%
        }
/* 순위 */

/* 스크롤바 커스텀 */
#activityCard .activity-table-wrap {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
    scrollbar-gutter: stable both-edges
}

    #activityCard .activity-table-wrap::-webkit-scrollbar {
        width: 10px;
        height: 10px
    }

    #activityCard .activity-table-wrap::-webkit-scrollbar-track {
        background: var(--scroll-track);
        border-radius: 999px
    }

    #activityCard .activity-table-wrap::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg,var(--scroll-thumb) 0%,rgba(79,70,229,.55) 100%);
        border-radius: 999px;
        border: 2px solid transparent;
        background-clip: padding-box;
        box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset
    }

        #activityCard .activity-table-wrap::-webkit-scrollbar-thumb:hover {
            background: linear-gradient(180deg,var(--scroll-thumb-hover) 0%,rgba(79,70,229,1) 100%)
        }
