@font-face {
    font-family: 'D2Coding';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_three@1.0/D2Coding.woff') format('woff');
    font-weight: normal;
    font-display: swap;
}

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --border: #2a2d3e;
    --accent: #6c8eff;
    --accent-dim: rgba(108,142,255,0.12);
    --text: #e2e4f0;
    --muted: #7b7f9e;
    --green: #4ade80;
    --yellow: #facc15;
    --red: #f87171;
    --thinking-bg: rgba(250,204,21,0.06);
    --thinking-border: rgba(250,204,21,0.25);
    --radius: 10px;
    --font: 'Pretendard','Noto Sans KR',system-ui,sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
    padding: 32px 20px 80px;
}

html {
    overflow-y: scroll;
    font-family: D2Coding, monospace;
}

.tabs {
    max-width: 860px;
    margin: 0 auto 20px;
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 18px;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

    .tab-btn.active {
        color: var(--accent);
        border-bottom-color: var(--accent);
    }

.tab-panel {
    display: none;
}

    .tab-panel.active {
        display: block;
    }

.search-box {
    max-width: 860px;
    margin: 0 auto 28px;
    display: flex;
    gap: 10px;
    align-items: center;
}

    .search-box input {
        flex: 1;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        color: var(--text);
        font-size: 1rem;
        font-family: var(--font);
        padding: 12px 16px;
        outline: none;
        transition: border-color 0.15s;
    }

        .search-box input:focus {
            border-color: var(--accent);
        }

        .search-box input::placeholder {
            color: var(--muted);
        }

    .search-box button {
        background: var(--accent);
        border: none;
        border-radius: var(--radius);
        color: #fff;
        cursor: pointer;
        font-size: 0.95rem;
        font-family: var(--font);
        font-weight: 600;
        padding: 12px 24px;
        transition: opacity 0.15s;
        white-space: nowrap;
    }

        .search-box button:hover {
            opacity: 0.85;
        }

        .search-box button:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

.shortcut-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 12px 16px;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

    .shortcut-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

.status {
    max-width: 860px;
    margin: 0 auto 20px;
    font-size: 0.85rem;
    color: var(--muted);
    min-height: 20px;
}

    .status.error {
        color: var(--red);
    }

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.query-tag {
    display: inline-block;
    background: var(--accent-dim);
    border: 1px solid rgba(108,142,255,0.3);
    border-radius: 6px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 8px;
    margin-left: 8px;
    vertical-align: middle;
}

.time-tag {
    font-size: 0.75rem;
    color: var(--muted);
    margin-left: 10px;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}

.results {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.section-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s;
    cursor: pointer;
}

    .card:hover {
        border-color: var(--accent);
    }

    .card.open {
        border-color: var(--accent);
    }

.card-header {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 0 10px;
    align-items: center;
    padding: 12px 14px;
    user-select: none;
}

.card-id {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--accent-dim);
    border-radius: 6px;
    padding: 3px 0;
    text-align: center;
}

.card-question {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.card-score {
    font-size: 0.78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.score-vhigh {
    color: #22c55e;
}

.score-high {
    color: #4ade80;
}

.score-mid {
    color: #facc15;
}

.score-low {
    color: #f97316;
}

.score-vlow {
    color: #ef4444;
}

.score-none {
    color: #9ca3af;
}

.card-chevron {
    font-size: 0.6rem;
    color: var(--muted);
    transition: transform 0.2s;
}

.card.open .card-chevron {
    transform: rotate(180deg);
}

.card-body {
    display: none;
    border-top: 1px solid var(--border);
    padding: 12px 14px 12px 60px;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
}

.card.open .card-body {
    display: block;
}

.empty {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 12px 0;
}

.rag-wrap {
    max-width: 860px;
    margin: 0 auto;
}

.thinking-box {
    background: var(--thinking-bg);
    border: 1px solid var(--thinking-border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
}

.thinking-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--yellow);
    user-select: none;
}

    .thinking-toggle .t-chevron {
        font-size: 0.6rem;
        transition: transform 0.2s;
    }

.thinking-box.open .t-chevron {
    transform: rotate(180deg);
}

.thinking-content {
    display: none;
    padding: 10px 14px 12px;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    border-top: 1px solid var(--thinking-border);
    max-height: 300px;
    overflow-y: auto;
}

.thinking-box.open .thinking-content {
    display: block;
}

.rag-answer-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    font-size: 0.93rem;
    line-height: 1.8;
    color: var(--text);
    min-height: 80px;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 20px;
}

    .rag-answer-box.empty-state {
        color: var(--muted);
        font-size: 0.85rem;
    }

.cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent);
    vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
    margin-left: 2px;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

.rag-sources-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.legend-panel {
    position: fixed;
    top: 50%;
    right: 24px;
    transform: translateY(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    width: 190px;
}

.legend-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
}

    .legend-row:not(:last-child) {
        border-bottom: 1px solid var(--border);
    }

.legend-score {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
}

.legend-meaning {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

    .legend-dot.d-vhigh {
        background: linear-gradient(135deg, #4ade80, #22c55e);
    }

    .legend-dot.d-high {
        background: linear-gradient(135deg, #4ade80, #22c55e);
    }

    .legend-dot.d-mid {
        background: linear-gradient(135deg, #facc15, #f59e0b);
    }

    .legend-dot.d-low {
        background: linear-gradient(135deg, #fb923c, #f97316);
    }

    .legend-dot.d-vlow {
        background: linear-gradient(135deg, #f87171, #ef4444);
    }

    .legend-dot.d-none {
        background: #9ca3af;
    }

@media (max-width: 1300px) {
    .legend-panel {
        display: none;
    }
}
