/* 짠툴 읽을거리 — 목록·글 공통 스타일 (index.html 색 변수와 맞춘다) */
:root {
    --bg: #ffffff; --card: #f8f9fa; --text: #212529; --sub: #6c757d;
    --line: #dee2e6; --primary: #0d6efd; --primary-light: rgba(13,110,253,.09);
    --badge: #e9ecef;
}
[data-theme="dark"] {
    --bg: #121212; --card: #1e1f23; --text: #e4e6eb; --sub: #9ca3af;
    --line: #2e3035; --primary: #3b82f6; --primary-light: rgba(59,130,246,.16);
    --badge: #2a2b2f;
}
* { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
    line-height: 1.8; font-size: 16px; word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--primary); }
img { max-width: 100%; height: auto; }

/* 머리말 */
.top {
    position: sticky; top: 0; z-index: 50; background: var(--bg);
    border-bottom: 1px solid var(--line);
}
.top-in {
    max-width: 1080px; margin: 0 auto; padding: 12px 18px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.top a.brand { color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.top nav { display: flex; gap: 6px; align-items: center; }
.top nav a {
    color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem;
    padding: 8px 12px; border-radius: 9px;
}
.top nav a:hover { background: var(--primary-light); color: var(--primary); }
.top nav a.go { background: var(--primary); color: #fff; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 18px 60px; }
.narrow { max-width: 760px; }

/* 목록 첫머리 */
.hero { padding: 22px 0 30px; border-bottom: 1px solid var(--line); margin-bottom: 30px; }
.hero h1 { font-size: 1.9rem; margin: 0 0 8px; line-height: 1.35; }
.hero p { margin: 0; color: var(--sub); }

/* 분류 단추 */
.cats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.cats button {
    border: 1px solid var(--line); background: var(--bg); color: var(--text);
    padding: 9px 15px; border-radius: 999px; font-size: .9rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
}
.cats button:hover { border-color: var(--primary); color: var(--primary); }
.cats button.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 글 목록 */
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.item {
    border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
    background: var(--bg); text-decoration: none; color: inherit; display: flex; flex-direction: column;
    transition: box-shadow .15s, transform .15s;
}
.item:hover { box-shadow: 0 6px 20px rgba(0,0,0,.09); transform: translateY(-2px); }
.item .thumb { aspect-ratio: 16/9; background: var(--card); object-fit: cover; width: 100%; display: block;
    background-size: cover; background-position: center; background-repeat: no-repeat; }
.item .body { padding: 16px 17px 18px; flex: 1; display: flex; flex-direction: column; }
.item .cat { font-size: .78rem; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.item h2 { font-size: 1.05rem; margin: 0 0 8px; line-height: 1.45; }
.item p { margin: 0; font-size: .89rem; color: var(--sub); line-height: 1.65; flex: 1; }
.item .date { margin-top: 12px; font-size: .8rem; color: var(--sub); }
.empty { color: var(--sub); padding: 40px 0; text-align: center; }

/* 글 본문 */
.post-head { margin-bottom: 26px; }
.post-head .cat { font-size: .85rem; font-weight: 700; color: var(--primary); }
.post-head h1 { font-size: 1.75rem; line-height: 1.38; margin: 8px 0 10px; }
.post-head .meta { color: var(--sub); font-size: .88rem; }
.post-cover { width: 100%; border-radius: 14px; margin-bottom: 30px;
    aspect-ratio: 16/9; background: var(--card);
    background-size: cover; background-position: center; background-repeat: no-repeat; }

.post h2 { font-size: 1.3rem; margin: 40px 0 12px; line-height: 1.4; }
.post h3 { font-size: 1.08rem; margin: 28px 0 8px; }
.post p { margin: 0 0 16px; }
.post ul, .post ol { margin: 0 0 16px; padding-left: 1.4em; }
.post li { margin: 6px 0; }
.post figure { margin: 26px 0; }
.post figure img { width: 100%; max-width: 100%; border: 1px solid var(--line); border-radius: 12px; display: block; }
/* 아직 안 그려진 그림이어도 가로로 넘치지 않게 — 자리만 잡아 둔다 */
.post figure img:not([src]), .post figure img[data-missing] {
    aspect-ratio: 16/9; background: var(--card); border-style: dashed;
}
.post figcaption { margin-top: 9px; font-size: .86rem; color: var(--sub); text-align: center; }
/* 코드 — 좁은 화면에서 가로로 넘치지 않게 */
.post code {
    background: var(--card); border: 1px solid var(--line); border-radius: 6px;
    padding: 1px 5px; font-size: .9em; word-break: break-all; overflow-wrap: anywhere;
}
.post pre {
    margin: 20px 0; padding: 14px 16px; background: var(--card);
    border: 1px solid var(--line); border-radius: 12px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
}
.post pre code {
    background: none; border: 0; padding: 0; font-size: .88rem; line-height: 1.7;
    white-space: pre; word-break: normal; overflow-wrap: normal; display: block;
}
.post blockquote {
    margin: 22px 0; padding: 15px 19px; background: var(--card);
    border-left: 4px solid var(--primary); border-radius: 0 10px 10px 0;
}
.post blockquote p:last-child { margin: 0; }
.post table { width: 100%; border-collapse: collapse; font-size: .93rem; margin: 20px 0; }
.post th, .post td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
.post th { background: var(--card); font-weight: 700; }

/* 글 끝 도구 안내 */
.try {
    margin: 40px 0 10px; padding: 24px 22px; border: 2px solid var(--primary);
    border-radius: 14px; background: var(--primary-light);
}
.try h3 { margin: 0 0 8px; font-size: 1.1rem; }
.try p { margin: 0 0 14px; font-size: .94rem; }
.try a.btn {
    display: inline-block; background: var(--primary); color: #fff; text-decoration: none;
    font-weight: 700; padding: 12px 22px; border-radius: 10px;
}

/* 다음 글 */
.more { margin-top: 44px; padding-top: 26px; border-top: 1px solid var(--line); }
.more h3 { font-size: 1.05rem; margin: 0 0 14px; }
.more ul { list-style: none; margin: 0; padding: 0; }
.more li { margin: 9px 0; }
.more a { text-decoration: none; font-weight: 600; }

/* 바닥글 */
.foot {
    margin-top: 54px; padding: 24px 0 34px; border-top: 1px solid var(--line);
    color: var(--sub); font-size: .82rem; line-height: 1.75;
}
.foot nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.foot nav a { color: var(--text); text-decoration: none; font-weight: 600; padding: 4px 0; }

@media (max-width: 600px) {
    .hero h1 { font-size: 1.5rem; }
    .post-head h1 { font-size: 1.4rem; }
    .wrap { padding: 20px 16px 50px; }
    .list { grid-template-columns: 1fr; }
}
