:root {
    --page-bg: var(--bg);
    --r:       16px;
    --r-sm:    8px;
}

body { background: #fff; }

/* ── 페이지 히어로 ───────────────────────────── */
.lib-hero {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 2.5rem 0 0;
}
.lib-hero-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 2rem;
}
.lib-hero-label {
    display: inline-block;
    font-size: var(--fs-12); font-weight: 700; letter-spacing: .1em;
    text-transform: uppercase; color: var(--accent);
    margin-bottom: .5rem;
}
.lib-hero h1 {
    font-size: clamp(var(--fs-22), 3vw, var(--fs-32));
    font-weight: 700; letter-spacing: -.01em; color: var(--text);
    line-height: 1.3; margin-bottom: .5rem;
}
.lib-hero-sub {
    font-size: var(--fs-14); font-weight: 400; color: var(--text); margin-bottom: 1.75rem;
}
.lib-count-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    background: var(--accent-tint); color: var(--accent);
    font-size: var(--fs-13); font-weight: 400; padding: .25rem .7rem;
    border-radius: 999px;
}

/* ── 검색/필터 바 ─────────────────────────────── */
.lib-toolbar {
    position: sticky;
    top: 68px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.lib-toolbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: .75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.lib-right-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.lib-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    width: 220px;
    height: 36px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 14px;
}

.lib-search input {
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--fs-14);
    font-family: inherit;
    color: var(--text);
    width: 100%;
}

.lib-search i { color: var(--text-muted); font-size: var(--fs-16); }

.lib-filter-like {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 36px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: var(--fs-13);
    font-weight: 400;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
}
.lib-filter-like i { font-size: var(--fs-12); color: var(--danger); }
.lib-filter-like:hover {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}
.lib-filter-like.active {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
    font-weight: 400;
}
.lib-filter-like.active i,
.lib-filter-like:hover i { color: var(--bg); }

/* ── 모양 / 공간 셀렉트 박스 ──────────────────── */
.lib-select-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.lib-select {
    height: 36px;
    padding: 0 32px 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235A6B69' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'/%3E%3C/svg%3E") no-repeat right 10px center;
    background-size: 13px;
    appearance: none;
    -webkit-appearance: none;
    font-size: var(--fs-13);
    font-weight: 400;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.12s;
}
.lib-select:hover { border-color: var(--text); }
.lib-select:focus { outline: none; border-color: var(--text); }

.lib-result-count {
    display: none;
    white-space: nowrap;
    font-size: var(--fs-12);
    color: var(--text-muted);
}
.lib-result-count strong { color: var(--text-muted); font-weight: 700; }

/* ── 메인 영역 ───────────────────────────────── */
.lib-main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
}

/* ── 매소너리 그리드 ──────────────────────────── */
.lib-masonry {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    align-items: start;
}

.lib-item {
    position: relative;
    border-radius: var(--r);
    overflow: hidden;
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(var(--text-rgb), 0.04);
    transition: box-shadow 0.2s, transform 0.2s;
}

.lib-item:hover {
    box-shadow: 0 8px 20px rgba(var(--text-rgb), 0.09);
    transform: translateY(-2px);
}

.lib-item:hover .lib-overlay {
    opacity: 1;
}

.lib-item:hover .lib-card-img svg,
.lib-item:hover .lib-card-img canvas {
    transform: scale(1.03);
    transition: transform 0.3s ease;
}


/* ── 카드 이미지 영역 ─────────────────────────── */
.lib-card-img {
    width: 100%;
    overflow: hidden;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.lib-card-img svg {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.3s ease;
}

.lib-card-img img {
    transition: transform 0.3s ease;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ── 오버레이 ─────────────────────────────────── */
.lib-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--text-rgb), 0.38);
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
}

.lib-overlay-top {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.lib-overlay-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* ── 아이콘 버튼 (좋아요 / 보드) ─────────────── */
.lib-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(var(--bg-rgb), 0.9);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-16);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, transform 0.12s;
}
.lib-icon-btn:hover { background: var(--bg); transform: scale(1.08); }

.lib-like-btn.liked { color: var(--danger); background: var(--bg); }
.lib-like-btn.liked i { animation: heartPop 0.25s ease; }

@keyframes heartPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.lib-overlay-title {
    display: none;
}

.lib-overlay-actions {
    display: flex;
    gap: 6px;
    width: 100%;
    justify-content: center;
}

.lib-btn {
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    border: none;
    font-size: var(--fs-13);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.lib-btn-primary {
    background: var(--danger);
    color: var(--bg);
}
.lib-btn-primary:hover { background: var(--danger-hover); }

.lib-btn-secondary {
    background: rgba(var(--bg-rgb), 0.9);
    color: var(--text);
}
.lib-btn-secondary:hover { background: var(--bg); }

/* ── 카드 하단 정보 ──────────────────────────── */
.lib-card-body {
    padding: 10px 12px 12px;
    background: #fff;
}

.lib-card-name {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.2px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-card-engine-icon { display: inline-flex; align-items: center; flex-shrink: 0; color: var(--text-muted); }
.lib-card-engine-icon svg { width: 13px; height: 13px; }

.lib-card-sub {
    font-size: var(--fs-12);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 섹션 타이틀 ──────────────────────────────── */
.lib-section-title {
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 28px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── 보드 모달 ───────────────────────────────── */
.bm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(var(--text-rgb), 0.45);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bm-modal {
    background: var(--bg);
    border-radius: var(--r);
    width: 340px;
    max-width: 92vw;
    box-shadow: 0 20px 60px rgba(var(--text-rgb), 0.18);
    overflow: hidden;
}

.bm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--border);
}

.bm-title {
    font-size: var(--fs-16);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.bm-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: var(--fs-16);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.12s;
}
.bm-close:hover { color: var(--text); }

.bm-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 8px 0;
}

.bm-empty {
    padding: 24px 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--fs-13);
}

.bm-board-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    cursor: pointer;
    transition: background 0.1s;
}
.bm-board-row:hover { background: var(--bg); }

.bm-board-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    background: var(--accent-tint);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-16);
    flex-shrink: 0;
}

.bm-board-info { flex: 1; min-width: 0; }
.bm-board-name {
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bm-board-count { font-size: var(--fs-12); color: var(--text-muted); margin-top: 1px; }
.bm-board-plus { color: var(--text-muted); font-size: var(--fs-18); }

.bm-divider { border: none; border-top: 1px solid var(--border); }

.bm-new {
    display: flex;
    gap: 8px;
    padding: 12px 14px 14px;
}

.bm-input {
    flex: 1;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0 12px;
    font-size: var(--fs-14);
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.12s;
}
.bm-input:focus { border-color: var(--accent); background: var(--bg); }

.bm-create-btn {
    height: 36px;
    padding: 0 14px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: var(--r-sm);
    font-size: var(--fs-14);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
}
.bm-create-btn:hover { background: var(--accent-hover); }

/* ── 토스트 ──────────────────────────────────── */
.lib-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--text);
    color: var(--bg);
    font-size: var(--fs-14);
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
    z-index: 9999;
}
.lib-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── 더 보기 버튼 ────────────────────────────── */
.lib-loadmore-btn {
    height: 40px;
    padding: 0 28px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: var(--fs-14);
    font-weight: 600;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.12s, border-color 0.12s;
}
.lib-loadmore-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.lib-loadmore-btn:disabled { opacity: 0.5; cursor: default; }

#libLoadMoreSpinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: libSpin 0.6s linear infinite;
}
@keyframes libSpin { to { transform: rotate(360deg); } }

/* ── 반응형 ──────────────────────────────────── */
@media (max-width: 900px) {
    .lib-masonry { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .lib-masonry { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .lib-main { padding: 1.4rem 1rem 3rem; }
    .lib-select-row { flex-basis: 100%; }
    .lib-select { flex: 1; }
    .lib-right-group { flex-basis: 100%; }
    .lib-search { flex: 1; width: auto; }
}
