/* RAGPRS 새 화면 — 이미지·아이콘 폰트 없이 CSS 하나. 포인트 색은 차콜 그레이
   글꼴: Pretendard(비동기) → 시스템 글꼴 순서. 크기는 rem(기본 16px) */
:root {
    --bg: #f3f3f4;
    --surface: #ffffff;
    --text: #18191b;
    --text-2: #3d3f43;
    --sub: #5f6166;
    --muted: #8e9095;
    --line: #e6e6e8;
    --line-strong: #d6d6d9;
    --accent: #3a3d43;
    --accent-hover: #232529;
    --accent-ink: #ffffff;
    --accent-soft: #eef0f2;
    --danger: #d63c3c;
    --new: #5b5f66;
    --hover: #f7f7f8;
    --radius: 14px;
    --wrap: 1320px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111112;
        --surface: #1a1a1c;
        --text: #eceef1;
        --text-2: #c9cdd3;
        --sub: #a0a7b1;
        --muted: #7c838d;
        --line: #29292c;
        --line-strong: #36363a;
        --accent: #d4d7dc;
        --accent-hover: #eceef1;
        --accent-ink: #141619;
        --accent-soft: #28282c;
        --danger: #ff7a7a;
        --new: #9aa0a8;
        --hover: #202023;
        --shadow: none;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: 16px; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "맑은 고딕", sans-serif;
    font-size: 1rem;
    line-height: 1.65;
    letter-spacing: -0.01em;
    word-break: keep-all;
    overflow-wrap: anywhere;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { letter-spacing: -0.025em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 50; background: var(--surface); padding: 6px 10px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- 머리 ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; gap: 28px; height: 64px; }
.brand { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-en { font-size: 1.375rem; font-weight: 900; letter-spacing: 0.08em; color: var(--text); line-height: 1; }
.brand-ko { font-size: .9375rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.brand:hover .brand-ko { color: var(--text); }
.menu { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; height: 100%; }
.menu::-webkit-scrollbar { display: none; }
.menu a {
    display: inline-flex; align-items: center; padding: 0 12px; white-space: nowrap;
    color: var(--sub); font-weight: 600; font-size: .9375rem; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.menu a:hover { color: var(--text); }
.menu a[aria-current] { color: var(--text); border-bottom-color: var(--accent); }
.user { display: flex; gap: 14px; font-size: .875rem; white-space: nowrap; color: var(--sub); }
.user .who { color: var(--text); font-weight: 700; }

/* ---------- 본문 + 채팅 두 칸 ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
main { padding-top: 28px; padding-bottom: 56px; min-height: 60vh; min-width: 0; }

/* ---------- 공통 상자 ---------- */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; margin-bottom: 16px; box-shadow: var(--shadow); }
.empty, .muted { color: var(--muted); }
.note { color: var(--sub); font-size: .875rem; margin: 0; }
.error { color: var(--danger); font-weight: 600; }

/* ---------- 버튼 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 42px; padding: 0 18px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
    font-size: .9375rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn[disabled] { opacity: .6; cursor: progress; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 0; }

/* ---------- 작은 표시 ---------- */
.tag {
    display: inline-flex; align-items: center; height: 22px; padding: 0 8px; margin-right: 6px; border-radius: 6px;
    font-size: .75rem; font-weight: 700; background: var(--hover); color: var(--sub); vertical-align: 2px; border: 1px solid var(--line);
}
.tag.strong { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.re { font-size: .8125rem; color: var(--muted); margin-right: 4px; font-weight: 600; }
.re::before { content: "↳ "; }
.cmt {
    display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 20px; padding: 0 7px; margin-left: 6px;
    border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .75rem; font-weight: 800; vertical-align: 2px;
}
.new {
    display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-left: 4px; border-radius: 50%;
    background: var(--new); color: #fff; font-size: .625rem; font-weight: 900; vertical-align: 2px; letter-spacing: 0;
}
.hot { margin-left: 6px; color: var(--danger); font-size: .75rem; font-weight: 800; vertical-align: 1px; }

/* ---------- 목록 ---------- */
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.head-row h1 { margin: 0; font-size: 1.625rem; font-weight: 800; }
.cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.cats a { height: 34px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: .875rem; font-weight: 600; color: var(--sub); }
.cats a[aria-current] { border-color: var(--text); background: var(--text); color: var(--surface); }
.result { color: var(--sub); font-size: .9375rem; margin: 0 0 12px; }
.result a { color: var(--accent); font-weight: 600; }

.list { list-style: none; margin: 0 0 8px; padding: 0; overflow: hidden; }
.list .row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 24px;
    padding: 16px 28px; border-top: 1px solid var(--line); transition: background .12s;
}
.list .row:first-child { border-top: 0; }
.list .row:hover { background: var(--hover); }
.list .row.notice { background: var(--accent-soft); }
.list .title { font-size: 1.0625rem; font-weight: 500; line-height: 1.5; color: var(--text); min-width: 0; }
.list .title:visited .subj { color: var(--sub); }
.list .title:hover .subj { color: var(--accent); }
.list .meta { display: flex; align-items: center; gap: 0; color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.list .meta > span + span::before { content: ""; display: inline-block; width: 1px; height: 10px; background: var(--line-strong); margin: 0 10px; vertical-align: 0; }
.list .meta .name { color: var(--sub); font-weight: 600; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
.list .empty { padding: 56px 0; text-align: center; list-style: none; }

.pages { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin: 24px 0 18px; }
.pages a, .pages strong, .pages .gap { min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; border-radius: 10px; font-size: .9375rem; font-weight: 600; }
.pages a { color: var(--sub); }
.pages a:hover { background: var(--surface); color: var(--text); }
.pages strong { background: var(--text); color: var(--surface); }
.pages .gap { color: var(--muted); min-width: 20px; }

.search { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.search select, .search input,
.write-form input, .write-form select, .write-form textarea,
.cmt-form input, .cmt-form textarea, .confirm input {
    height: 44px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
    border-radius: 10px; padding: 0 14px; font-size: 1rem; transition: border-color .15s, box-shadow .15s;
}
.search input:focus, .write-form input:focus, .write-form select:focus, .write-form textarea:focus,
.cmt-form input:focus, .cmt-form textarea:focus, .confirm input:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.search select { padding-right: 8px; }
.search input { width: min(300px, 50vw); }

/* ---------- 글 보기 ---------- */
.post { padding: 36px 44px; }
.post-head { border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 28px; }
.crumb { margin: 0 0 10px; font-size: .875rem; font-weight: 700; }
.crumb a { color: var(--accent); }
.post-head h1 { margin: 0 0 14px; font-size: 1.75rem; font-weight: 800; line-height: 1.4; color: var(--text); }
.post-head .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin: 0; color: var(--muted); font-size: .875rem; }
.post-head .meta > * + *::before { content: ""; display: inline-block; width: 1px; height: 11px; background: var(--line-strong); margin: 0 12px; }
.post-head .name { color: var(--text-2); font-weight: 700; }
.content { font-size: 1.0625rem; line-height: 1.9; color: var(--text); min-height: 100px; max-width: 760px; }
.content p { margin: 0 0 1.1em; }
.content img { border-radius: 10px; margin: 6px 0; }
.content img.emo { vertical-align: middle; margin: 0; border-radius: 0; }
.content table { border-collapse: collapse; max-width: 100%; display: block; overflow-x: auto; font-size: .9375rem; }
.content td, .content th { border: 1px solid var(--line); padding: 6px 10px; }
.content blockquote { margin: 1.2em 0; padding: 4px 18px; border-left: 3px solid var(--line-strong); color: var(--sub); }
.content pre { background: var(--bg); padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: .875rem; line-height: 1.6; }
.content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.content iframe { max-width: 100%; border: 0; border-radius: 10px; }
.yt { display: inline-flex; align-items: center; height: 44px; padding: 0 16px; border-radius: 10px; background: var(--accent-soft); font-weight: 700; text-decoration: none !important; }
.yt-frame { position: relative; width: 100%; max-width: 720px; aspect-ratio: 16 / 9; margin: 8px 0; }
.yt-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 10px; }
.links { margin: 28px 0 0; padding: 14px 18px 14px 34px; background: var(--hover); border-radius: 10px; font-size: .9375rem; max-width: 760px; }
.links a { color: var(--accent); word-break: break-all; }
.post-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.post-foot .primary { margin-left: auto; }

/* ---------- 댓글 ---------- */
.comments { padding: 28px 44px; }
.comments h2 { font-size: 1.1875rem; font-weight: 800; margin: 0 0 8px; }
.comments .count { color: var(--accent); margin-left: 2px; }
.cmt-list { list-style: none; margin: 0; padding: 0; }
.cmt-list .cm { padding: 18px 0; border-top: 1px solid var(--line); }
.cmt-list .cm:first-child { border-top: 0; }
.cmt-list .cm[style] { border-left: 2px solid var(--line); padding-left: 14px; }
.cmt-list .cm:target { background: var(--accent-soft); border-radius: 10px; padding-left: 14px; padding-right: 14px; }
.cmt-head { display: flex; gap: 10px; align-items: center; font-size: .875rem; }
.cmt-head strong { font-weight: 700; color: var(--text); }
.cmt-head time { color: var(--muted); font-size: .8125rem; }
.cmt-head .del { margin-left: auto; color: var(--muted); font-size: .8125rem; }
.cmt-head .del:hover { color: var(--danger); }
.cmt-body { margin-top: 6px; font-size: 1rem; line-height: 1.75; color: var(--text-2); }
.cmt-form { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.cmt-form textarea { width: 100%; height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.6; resize: vertical; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 label { display: grid; gap: 6px; font-size: .875rem; font-weight: 600; color: var(--sub); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: .9375rem; color: var(--sub); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.captcha { min-height: 78px; }

.prevnext { padding: 0; overflow: hidden; }
.prevnext a { display: flex; align-items: center; gap: 16px; padding: 16px 28px; border-top: 1px solid var(--line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .9375rem; }
.prevnext a:first-child { border-top: 0; }
.prevnext a:hover { background: var(--hover); }
.prevnext span { color: var(--muted); font-size: .8125rem; font-weight: 700; flex: none; width: 4em; }

/* ---------- 글쓰기 · 확인 ---------- */
.write { padding: 32px 40px; }
.write h1, .confirm h1 { font-size: 1.375rem; font-weight: 800; margin: 0 0 20px; }
.write-form { display: grid; gap: 16px; }
.write-form > label, .confirm label { display: grid; gap: 6px; font-size: .875rem; font-weight: 600; color: var(--sub); }
.write-form input, .write-form select, .write-form textarea { width: 100%; }
.write-form textarea { height: auto; min-height: 320px; padding: 14px; line-height: 1.75; resize: vertical; }
.more { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.more summary { cursor: pointer; color: var(--sub); font-size: .9375rem; font-weight: 600; }
.more label { display: grid; gap: 6px; margin-top: 12px; font-size: .875rem; font-weight: 600; color: var(--sub); }
.more input { width: 100%; }
.opts { display: flex; gap: 20px; flex-wrap: wrap; }
.confirm { max-width: 520px; margin-left: auto; margin-right: auto; padding: 32px; }
.confirm p { color: var(--text-2); }
.msg { max-width: 520px; margin: 48px auto; text-align: center; padding: 36px 28px; font-size: 1.0625rem; }
.msg .actions { justify-content: center; }

/* ---------- 꼬리 ---------- */
.foot { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .8125rem; }
.foot-in { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; padding-top: 22px; padding-bottom: 22px; }
.foot-in span:first-child { font-weight: 800; color: var(--sub); letter-spacing: .02em; }
.foot a:hover { color: var(--accent); }

/* ---------- 채팅: PC 는 오른쪽에 고정 ---------- */
.chat {
    position: sticky; top: 92px; margin-top: 28px;
    height: calc(100vh - 116px); max-height: 780px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    display: flex; flex-direction: column; overflow: hidden;
}
.chat-head { display: flex; justify-content: space-between; align-items: center; height: 48px; padding: 0 16px; border-bottom: 1px solid var(--line); font-size: .9375rem; }
.chat-head strong { font-weight: 800; }
.chat-head button { border: 0; background: none; color: var(--sub); cursor: pointer; font-size: .875rem; font-weight: 600; padding: 6px; }
.chat-close, .chat-btn { display: none; }
.chat-body { flex: 1; min-height: 0; }
.chat-body u-chat { display: block; width: 100%; height: 100%; }

/* ---------- 태블릿·모바일 ---------- */
@media (max-width: 1023px) {
    .layout { display: block; }
    .chat {
        display: none; position: fixed; z-index: 31; top: auto; margin: 0;
        right: 16px; bottom: 84px; width: min(400px, calc(100vw - 32px)); height: min(620px, calc(100dvh - 160px)); max-height: none;
        box-shadow: 0 16px 40px rgba(0, 0, 0, .22); border-radius: 16px;
    }
    .chat.open { display: flex; }
    .chat-close { display: inline; }
    .chat-btn {
        display: inline-flex; align-items: center; position: fixed; right: 16px; bottom: 20px; z-index: 30;
        height: 52px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
        font-size: 1rem; font-weight: 800; box-shadow: 0 6px 18px rgba(0, 0, 0, .28); cursor: pointer;
    }
    .foot-in { padding-bottom: 96px; }
}

@media (max-width: 767px) {
    .wrap { padding: 0 16px; }
    .top-in { height: 56px; gap: 16px; }
    .brand-en { font-size: 1.25rem; }
    .brand-ko { font-size: .875rem; }
    .menu a { padding: 0 10px; }
    main { padding-top: 18px; padding-bottom: 32px; }

    .head-row h1 { font-size: 1.375rem; }
    .btn { height: 44px; }

    /* 목록: 모바일은 화면 끝까지, 제목 아래 정보 */
    .list.box { padding: 0; margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; }
    .list .row { grid-template-columns: minmax(0, 1fr); padding: 15px 16px; gap: 6px; }
    .list .title { font-size: 1rem; line-height: 1.55; }
    .list .meta { font-size: .8125rem; }
    .list .meta > span + span::before { margin: 0 8px; }

    .search { flex-wrap: wrap; }
    .search select { flex: none; }
    .search input { flex: 1; width: auto; min-width: 0; }

    .box { padding: 20px; border-radius: 12px; }
    .post.box, .comments.box, .write.box { padding: 24px 18px; margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; }
    .post-head { padding-bottom: 16px; margin-bottom: 22px; }
    .post-head h1 { font-size: 1.375rem; }
    .content { font-size: 1.0625rem; line-height: 1.85; }
    .post-foot { margin-top: 28px; }
    .post-foot .btn { flex: 1; padding: 0 10px; }
    .post-foot .primary { margin-left: 0; flex-basis: 100%; }

    .prevnext.box { padding: 0; margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; }
    .prevnext a { padding: 15px 16px; }

    .row2 { grid-template-columns: 1fr; }
    .form-foot { flex-wrap: wrap; }
    .form-foot .btn { flex: 1; }
    .chat { right: 8px; left: 8px; width: auto; bottom: 84px; height: calc(100dvh - 150px); }
}

/* 관리자에게만 보이는 작성자 IP */
.ip { font-variant-numeric: tabular-nums; font-size: .75rem; color: var(--muted); letter-spacing: 0; }
.post-head .meta .ip, .cmt-head .ip { padding: 1px 6px; border-radius: 4px; background: var(--hover); border: 1px solid var(--line); }

/* 시간 제한 게시판 (예: 5분홍보) */
.board-note { margin: 6px 0 0; font-size: .875rem; color: var(--sub); }
.board-note strong { color: var(--text); }
.write-form .board-note { padding: 12px 14px; border-radius: 10px; background: var(--hover); border: 1px solid var(--line); }
.left { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-2); }
.list .meta .left { padding: 0 7px; border-radius: 999px; background: var(--accent-soft); }
.list .meta .left::before { display: none; }
.list .meta .left { margin-left: 10px; }
.list .row.expired, .post.expired .content { opacity: .45; }
.expired-note { color: var(--muted); font-weight: 600; }

/* 본문만 바꿔 끼우는 이동 중 표시 */
html.is-loading main { opacity: .55; transition: opacity .15s .12s; }
html.is-loading .top::after {
    content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 40%;
    background: var(--accent); animation: rg-load 1s ease-in-out infinite;
}
.top { position: sticky; }
@keyframes rg-load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) { html.is-loading .top::after { animation: none; width: 100%; } }

/* 상단 메뉴 뱃지: 시간 제한 게시판의 노출 중인 글 수 */
.menu a { position: relative; gap: 6px; }
.nb {
    display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .6875rem; font-weight: 800;
    letter-spacing: 0; font-variant-numeric: tabular-nums; line-height: 1;
}
.nb[hidden] { display: none; }
.nb.pulse { animation: rg-pulse 1.2s ease-out 2; }
@keyframes rg-pulse { 0% { box-shadow: 0 0 0 0 rgba(58, 61, 67, .45); } 100% { box-shadow: 0 0 0 9px rgba(58, 61, 67, 0); } }
.admin-note { color: var(--muted); font-size: .8125rem; }
@media (prefers-reduced-motion: reduce) { .nb.pulse { animation: none; } }
