/* ===== 기본 리셋 & 변수 ===== */
:root {
    --bg: #ffffff;
    --text: #24292f;
    --muted: #656d76;
    --primary: #0969da;
    --border: #d0d7de;
    --card-bg: #f6f8fa;
    --radius: 10px;
    --max-width: 1300px;
    --header-h: 56px;
    --accent-tint: transparent;   /* 팔레트로 색 고르면 선택색의 옅은 버전이 들어감 */
}

/* ===== 다크 모드 (data-theme="dark" 일 때 색 변수만 교체) ===== */
:root[data-theme="dark"] {
    /* --bg: #0d1117; */
    --bg: #131415;
    --text: #e6edf3;
    --muted: #8b949e;
    --primary: #58a6ff;
    --border: #30363d;
    /* --card-bg: #161b22; */
    --card-bg: #101216;
}
/* 변수로 안 묶인 일부 밝은 색들 다크용 보정 */
:root[data-theme="dark"] .post-summary,
:root[data-theme="dark"] .repo-desc { color: #adbac7; }
:root[data-theme="dark"] .cat-row:hover,
:root[data-theme="dark"] .page-link:hover,
:root[data-theme="dark"] .repo-card:hover { background: #21262d; }
:root[data-theme="dark"] .count { background: #30363d; color: #8b949e; }
:root[data-theme="dark"] .tag { background: rgba(56,139,253,0.15); color: #58a6ff; }
:root[data-theme="dark"] .post-content code,
:root[data-theme="dark"] .post-content pre { background: #161b22; }
:root[data-theme="dark"] .cat-tree .cat-tree { border-left-color: #30363d; }
:root[data-theme="dark"] .cat-row.lvl-3 { color: #adbac7; }
:root[data-theme="dark"] .page-link.disabled { color: #484f58; }

/* 부드러운 전환 */
body { transition: background 0.2s, color 0.2s; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
                 "Malgun Gothic", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.65;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* ===== 헤더 ===== */
.site-header {
    border-bottom: 1px solid var(--border);
    /* 기본 배경 위에 선택색 틴트를 덧칠 (틴트 transparent면 그냥 배경색) */
    background: linear-gradient(var(--accent-tint), var(--accent-tint)), var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
    height: var(--header-h);
}
.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 20px;
}
.brand { font-weight: 700; font-size: 1.2rem; color: var(--text); white-space: nowrap; }
.nav { display: flex; gap: 16px; flex: 1; margin-left: 48px; }  /* 숫자 키우면 더 오른쪽 */
.nav a { color: var(--text); font-weight: 600; font-size: 0.88rem; letter-spacing: 0.02em; }
.nav a:hover { color: var(--primary); text-decoration: none; }
/* nav 안 아이콘: 글자 높이에 맞춰 정렬·크기 */
.nav a { display: inline-flex; align-items: center; }
.nav .material-symbols-outlined { font-size: 22px; }

.search-form { display: flex; margin-left: auto; }
.search-form input {
    border: 1px solid var(--border);
    border-radius: var(--radius) 0 0 var(--radius);
    padding: 5px 11px;
    outline: none;
    font-size: 0.9rem;
    width: 160px;
}
.search-form button {
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--card-bg);
    padding: 5px 10px;
    cursor: pointer;
}

/* 다크모드 토글 버튼 */
.theme-btn {
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 38px; height: 34px;
    font-size: 1rem; cursor: pointer;
    line-height: 1;
}
.theme-btn:hover { border-color: var(--primary); }
.theme-btn { display: inline-flex; align-items: center; justify-content: center; }
.theme-btn .material-symbols-outlined { font-size: 20px; }
/* 다크모드일 때 헤더 토글 아이콘들(해·팔레트)은 흰색 */
:root[data-theme="dark"] .theme-btn .material-symbols-outlined { color: #fff; }

/* ===== 테마 색상 피커 ===== */
.color-picker-wrap { position: relative; }
.color-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 30;
}
.color-panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cp-title {
    flex: 1; font-weight: 700;
    border-left: 4px solid var(--primary); padding-left: 8px;
}
.cp-reset {
    border: 1px solid var(--border); background: var(--bg);
    border-radius: 8px; padding: 3px 9px; cursor: pointer; color: var(--text);
}
.cp-reset:hover { border-color: var(--primary); }
.cp-value {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; padding: 3px 10px; font-size: 0.85rem; min-width: 44px; text-align: center;
}

/* 무지개(색상환) 슬라이더 */
.hue-slider {
    width: 100%; height: 14px; border-radius: 7px;
    -webkit-appearance: none; appearance: none; cursor: pointer; outline: none;
    background: linear-gradient(to right,
        hsl(0,70%,50%), hsl(60,70%,50%), hsl(120,70%,50%),
        hsl(180,70%,50%), hsl(240,70%,50%), hsl(300,70%,50%), hsl(360,70%,50%));
}
.hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: #fff; border: 1px solid rgba(0,0,0,0.25);
    box-shadow: 0 1px 4px rgba(0,0,0,0.35); cursor: pointer;
}
.hue-slider::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%;
    background: #fff; border: 1px solid rgba(0,0,0,0.25); cursor: pointer;
}

/* ===== 3컬럼 레이아웃 ===== */
.container {
    max-width: var(--max-width);
    margin: 28px auto;
    padding: 0 0px;
    display: grid;
    grid-template-columns: 220px 1fr 220px;
    grid-template-areas: "left main right";
    gap: 48px;
    align-items: start;
}
.sidebar-left  { grid-area: left; }
.content       { grid-area: main; min-width: 0; }
.sidebar-right { grid-area: right; }

/* ===== 공통 사이드바 ===== */
.sidebar-left,
.sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: calc(var(--header-h) + 10px);
    max-height: calc(100vh - var(--header-h) - 20px);
    overflow-y: auto;
    scrollbar-width: none;
}
.sidebar-left::-webkit-scrollbar,
.sidebar-right::-webkit-scrollbar { display: none; }

/* ===== 카드 ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
/* 좌우 사이드바 카드: 선택색 틴트를 카드 배경 위에 덧칠 */
.sidebar-left .card,
.sidebar-right .card {
    background: linear-gradient(var(--accent-tint), var(--accent-tint)), var(--card-bg);
}
.card h3 {
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 12px;
}

/* ===== 왼쪽: 프로필 카드 ===== */
.profile-card {
    text-align: center;
}
.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}
/* 프로필 사진 (avatar 설정 시) — .avatar와 동일 크기의 원형 */
.avatar-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;          /* 비율 유지하며 원 안 꽉 채움 */
    display: block;
    margin: 0 auto 12px;
    border: 1px solid var(--border);
}
.profile-card h2 { font-size: 1.1rem; margin-bottom: 4px; }
.profile-card .muted { font-size: 0.82rem; line-height: 1.4; }

/* ===== 왼쪽: Contact 목록 ===== */
.contact-list { list-style: none; }
.contact-list li { padding: 4px 0; font-size: 0.88rem; }
.contact-list a { color: var(--text); }
.contact-list a:hover { color: var(--primary); text-decoration: none; }

/* ===== 공통: 사이드 리스트 ===== */
.side-list { list-style: none; }
.side-list li a {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    color: var(--text);
    font-size: 0.9rem;
}
.side-list li a:hover { color: var(--primary); text-decoration: none; }
.count {
    background: #eaeef2;
    color: var(--muted);
    border-radius: 20px;
    padding: 0 7px;
    font-size: 0.72rem;
    flex-shrink: 0;
}
.see-all { display: inline-block; margin-top: 10px; font-size: 0.82rem; }

/* ===== 오른쪽: 최근 글 목록 ===== */
.recent-list li a {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.88rem;
    padding: 5px 0;
    color: var(--text);
}
.recent-list li a:hover { color: var(--primary); text-decoration: none; }

/* ===== 태그 ===== */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    background: #ddf4ff;
    color: var(--primary);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.78rem;
}
.tag:hover { background: var(--primary); color: #fff; text-decoration: none; }
.tag-cloud.big .tag { font-size: 0.95rem; padding: 6px 14px; }

/* ===== 글 목록 ===== */
.page-title { font-size: 1.6rem; margin-bottom: 24px; }
.post-list { list-style: none; }
.post-item { padding: 22px 0; border-bottom: 1px solid var(--border); }
.post-item h2 { font-size: 1.25rem; color: var(--text); }
.post-link:hover h2 { color: var(--primary); }
.post-meta { color: var(--muted); font-size: 0.85rem; margin: 6px 0; }
.post-meta a { color: var(--muted); }
.post-summary { margin: 8px 0 12px; color: #444; }

/* ===== 글 상세 ===== */
.post-detail h1 { font-size: 2rem; margin-bottom: 8px; }
.post-content { margin-top: 24px; }
.post-content h1, .post-content h2, .post-content h3 { margin: 24px 0 12px; }
.post-content p { margin: 12px 0; }
.post-content ul, .post-content ol { margin: 12px 0 12px 24px; }
.post-content pre {
    background: #f6f8fa;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 16px 0;
}
.post-content code {
    background: #eff1f3;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
}
.post-content pre code { background: none; padding: 0; }
.post-content blockquote {
    border-left: 4px solid var(--border);
    padding-left: 16px;
    color: var(--muted);
    margin: 16px 0;
}
.post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}
.post-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    font-size: 0.9rem;
}
.post-content th, .post-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}
.post-content th { background: var(--card-bg); font-weight: 600; }

/* ===== 카테고리 목록 ===== */
.category-list { list-style: none; }
.category-list li a {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 1.1rem;
}

/* ===== 계층형 카테고리 트리 ===== */
.full-cat-tree { margin-top: 20px; }
/* 목록 기본 점(• ○ ■) 제거 — 토글 화살표(▸/▾)만 보이게 */
.cat-tree { list-style: none; padding-left: 0; margin: 0; }

.full-cat-tree > .cat-tree > li {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 18px 16px;
    margin-bottom: 16px;
}
.cat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    line-height: 1.4;
}
.cat-row:hover { background: #e9eef4; text-decoration: none; }
.cat-row .cat-name { flex: 0 1 auto; }
.cat-row.lvl-1 { font-size: 1.18rem; font-weight: 400; color: var(--primary); }
.cat-row.lvl-2 { font-size: 1.02rem; font-weight: 400; }
.cat-row.lvl-3 { font-size: 0.92rem; font-weight: 400; color: #4a5568; }
.cat-row.lvl-3 .cat-name::before { content: "└ "; color: #aab4c0; }

/* 토글(details/summary) — 클릭하면 하위 펼침 */
.cat-toggle > summary { cursor: pointer; list-style: none; }
.cat-toggle > summary::-webkit-details-marker { display: none; }   /* 사파리 기본 마커 제거 */
/* 커스텀 화살표: 접힘 ▸ / 펼침 ▾ */
.cat-toggle > summary .cat-name::before {
    content: "▸";
    display: inline-block;
    width: 1em; margin-right: 4px;
    color: var(--muted); font-size: 0.85em;
}
.cat-toggle[open] > summary .cat-name::before { content: "▾"; }

.cat-tree .cat-tree {
    margin: 2px 0 2px 9px;
    padding-left: 16px;
    border-left: 2px solid #e2e8f0;
}
.cat-row .count { font-size: 0.72rem; }

/* ===== 카테고리 상세 ===== */
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--muted); }
.section-title {
    font-size: 1.2rem;
    margin: 28px 0 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.sub-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 20px 0;
}
.sub-cat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
}
.sub-cat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    text-decoration: none;
    border-color: var(--primary);
}

/* ===== 프로젝트(깃허브 저장소) ===== */
.repo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.repo-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    color: var(--text);
    transition: box-shadow .15s;
}
.repo-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); text-decoration: none; }
.repo-card h3 { color: var(--primary); margin-bottom: 8px; overflow-wrap: anywhere; }
.repo-desc { font-size: 0.9rem; color: #444; min-height: 40px; }
.repo-meta { display: flex; gap: 14px; font-size: 0.8rem; color: var(--muted); margin-top: 10px; }
.lang { font-weight: 600; }

/* ===== 프로젝트 상세 페이지 ===== */
.proj-header { margin-bottom: 18px; }
.proj-desc { color: #444; margin: 6px 0 12px; }
.proj-links { display: flex; gap: 10px; margin-top: 12px; }
.btn {
    display: inline-block; padding: 8px 16px; border-radius: 8px;
    background: var(--primary); color: #fff; font-size: 0.9rem; font-weight: 600;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }

.proj-og {
    width: 100%; max-width: 640px; border: 1px solid var(--border);
    border-radius: 12px; margin: 18px 0; display: block;
}

/* 그래프 + 표 2단 */
.proj-info { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 640px) { .proj-info { grid-template-columns: 1fr; } }

/* 언어 비율 막대 (라이브러리 없이 CSS만) */
.lang-bar {
    display: flex; height: 14px; border-radius: 7px; overflow: hidden;
    background: var(--border); margin: 6px 0 14px;
}
.lang-bar span { height: 100%; }
.lang-legend { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.lang-legend li { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.lang-legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

/* 메타데이터 표 */
.meta-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.meta-table th, .meta-table td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.meta-table th { color: var(--muted); font-weight: 600; width: 40%; }

/* README 박스 */
.readme-card .readme-body { max-height: 640px; overflow-y: auto; }
.readme-body img { max-width: 100%; height: auto; }

/* ===== 글쓰기 폼 ===== */
.write-form { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.write-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.write-form input,
.write-form select,
.write-form textarea {
    font: inherit; font-weight: 400;
    padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text);
}
.write-form textarea { resize: vertical; min-height: 200px; font-family: "SF Mono", Menlo, Consolas, monospace; }
.write-form input:focus,
.write-form select:focus,
.write-form textarea:focus { outline: none; border-color: var(--primary); }
.write-actions { display: flex; gap: 10px; }

/* 글쓰기 - 카테고리 선택 트리 */
.cat-field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.cat-field-label small { font-weight: 400; }
.cat-select {
    max-height: 280px; overflow-y: auto;
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; background: var(--bg);
}
.cat-select-tree { list-style: none; padding-left: 0; margin: 0; font-weight: 400; }
/* 하위 들여쓰기 + 가이드선 */
.cat-select-tree .cat-select-tree {
    margin: 2px 0 2px 9px; padding-left: 14px; border-left: 2px solid var(--border);
}
/* 말단(라디오) 행 */
.cat-radio { cursor: pointer; }
/* .write-form label(세로배치)을 덮어 가로 배치: 라디오 왼쪽 · 텍스트 오른쪽 · 좌측 정렬 */
.cat-select .cat-radio { flex-direction: row; justify-content: flex-start; align-items: center; }
.cat-radio input { margin: 0 2px 0 0; }
.cat-radio input:checked + .cat-name { color: var(--primary); font-weight: 700; }

/* ===== 페이지네이션 ===== */
.pagination {
    display: flex; justify-content: center; gap: 6px;
    margin: 32px 0 8px;
}
.page-link {
    min-width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 0.9rem;
}
.page-link:hover { background: var(--card-bg); text-decoration: none; }
.page-link.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
    font-weight: 700;
}
.page-link.disabled {
    color: #c0c7ce; pointer-events: none;   /* 끝 페이지에서 클릭 막기 */
}

/* ===== 푸터 ===== */
.site-footer {
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 30px;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 40px;
}

/* ===== 반응형 ===== */
/* 중간 화면: 왼쪽 사이드바 숨김 */
@media (max-width: 1100px) {
    .container {
        grid-template-columns: 1fr 220px;
        grid-template-areas: "main right";
    }
    .sidebar-left { display: none; }
}
/* 모바일: 오른쪽 사이드바도 숨김 */
@media (max-width: 760px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-areas: "main";
    }
    .sidebar-right { display: none; }
    .nav { flex-wrap: wrap; gap: 10px; }
    .search-form input { width: 120px; }
}

/* ===== 글 선택 삭제 도구막대 (로컬 전용 UI) ===== */
.bulk-bar {
  display: block;
}
.bulk-bar > .bulk-check,
.bulk-bar > .btn-plain,
.bulk-bar > .bulk-count,
.bulk-bar > .btn-danger {
  vertical-align: middle;
  margin-right: .6rem;
}
.bulk-check {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  font-size: .9rem;
}
.bulk-count {
  font-size: .85rem;
}
.btn-plain {
  background: none;
  border: 1px solid var(--border, #d0d7de);
  border-radius: 6px;
  padding: .25rem .6rem;
  font-size: .85rem;
  cursor: pointer;
  color: inherit;
}
.btn-plain:hover {
  border-color: var(--accent, #0969da);
}
.btn-danger {
  background: #d1242f;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .3rem .8rem;
  font-size: .85rem;
  cursor: pointer;
}
.btn-danger:hover {
  background: #a40e26;
}

/* 체크박스가 붙은 글 항목 */
.post-item {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
}
.post-select {
  padding-top: .55rem;
  cursor: pointer;
}
.post-body {
  flex: 1;
  min-width: 0;
}

/* 삭제 결과 알림 */
.flash {
  margin: 0 0 1rem;
  padding: .6rem .9rem;
  border-radius: 6px;
  border: 1px solid var(--border, #d0d7de);
  background: var(--card, #f6f8fa);
  font-size: .9rem;
}

/* 글 상세의 삭제 버튼 */
.post-actions {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #d0d7de);
}
