/* =========================
   기본
========================= */
:root {
    --brand: #4f46e5;
    --muted: #94a3b8;
    --text: #e5e7eb;
}

* {
    box-sizing: border-box;
}

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

.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 10px
}

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

input, button {
    border-radius: 12px;
    border: 1px solid rgba(148,163,184,.35);
    background: #0b1220;
    color: #e5e7eb;
}

input {
    padding: 10px 12px;
    width: 100%;
    height: 42px
}

button {
    height: 42px;
    padding: 0 16px;
    cursor: pointer;
    background: var(--brand);
    border: 0;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

.muted {
    color: var(--muted);
    font-size: 12px
}

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

    .grid > div {
        min-width: 0
    }

.row {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap
}

.klist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px
}

.chip {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(148,163,184,.3);
    background: #0b1220;
    font-size: 12px
}

.table {
    width: 100%;
    border-collapse: collapse
}

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

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

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

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

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

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

/* =========================
   상단 입력 폼 전용 레이아웃
   (입력 2칸 + 버튼 고정폭 120px)
========================= */
.wrap > .card:first-child .grid {
    grid-template-columns: minmax(220px,1fr) minmax(420px,2fr) 120px; /* ← 버튼 칸 고정 */
    column-gap: 12px;
    align-items: end;
}

    .wrap > .card:first-child .grid > div {
        min-width: 0
    }

        .wrap > .card:first-child .grid > div:nth-child(3) {
            /* 버튼 칸 */
            justify-self: end;
        }

    .wrap > .card:first-child .grid .row {
        display: block
    }

        .wrap > .card:first-child .grid .row button {
            display: block;
            width: 100%;
            height: 42px; /* 칸을 꽉 채워 입력창과 같은 높이 */
        }

/* 태블릿: 버튼을 다음 줄로 */
@media (max-width: 980px) {
    .wrap > .card:first-child .grid {
        grid-template-columns: 1fr 1fr;
    }

        .wrap > .card:first-child .grid > div:nth-child(3) {
            grid-column: 1 / -1;
            justify-self: start;
            width: 160px; /* 태블릿에서 버튼 폭 살짝 넉넉하게 */
        }
}

/* 모바일: 한 줄에 하나 */
@media (max-width: 640px) {
    .wrap > .card:first-child .grid {
        grid-template-columns: 1fr;
    }

        .wrap > .card:first-child .grid > div:nth-child(3) {
            width: 100%;
        }

        .wrap > .card:first-child .grid .row button {
            width: 100%;
        }
}

/* =========================
   결과 메트릭 그리드(오버플로우 방지)
========================= */
#metrics {
    grid-template-columns: repeat(3,minmax(0,1fr)) !important;
    gap: 12px;
}

    #metrics > .card {
        min-width: 0
    }

    #metrics .muted {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis
    }

@media (max-width:900px) {
    #metrics {
        grid-template-columns: repeat(2,minmax(0,1fr)) !important
    }
}

@media (max-width:560px) {
    #metrics {
        grid-template-columns: 1fr !important
    }
}

/* =========================
   난이도 인사이트
========================= */
.insight-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px
}

.pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid rgba(148,163,184,.25)
}

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

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

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

    .pill.note {
        background: #0b1220;
        color: #cbd5e1
    }

.insight-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px
}

@media (max-width:800px) {
    .insight-grid {
        grid-template-columns: 1fr
    }
}

.insight-hint {
    font-size: 12px;
    color: #94a3b8
}
