/*
 * 기본 레이아웃 + 모든 레이아웃 스킨이 함께 쓰는 공통 UI (버튼, 폼, 카드, 위젯, 본문 등).
 * 색·모서리·그림자는 :root 변수로 정하므로 스킨은 변수만 바꿔도 전체 톤이 바뀐다.
 */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
    --primary: #3b5bfd;
    --primary-dark: #2a45d8;
    --text: #191f28;
    --muted: #6b7684;
    --line: #e8ebed;
    --bg: #f5f6f8;
    --surface: #fff;
    --surface-2: #f6f7f9;     /* 표 머리, 첨부 목록 등 옅은 면 */
    --input-bg: #f6f7f9;
    --accent-soft: color-mix(in srgb, var(--primary) 10%, transparent); /* 태그, 선택된 항목 */
    --warn-bg: #fff4d6;
    --warn-text: #8a5a00;
    --ok-bg: #e8f8ef;
    --ok-text: #11643b;
    --ok-line: #bfe8d0;
    --err-bg: #feeceb;
    --err-text: #b42318;
    --err-line: #fbcfcb;
    --danger: #e5484d;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow: 0 4px 12px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
    --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .18);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --header-bg: color-mix(in srgb, var(--surface) 78%, transparent);
}

/* 다크 모드: 스킨 옵션 "색 모드" 가 dark 이거나, auto 이면서 기기가 다크일 때 (html[data-mode]) */
:root[data-mode="dark"] {
    color-scheme: dark;
    --text: #e8eaed; --muted: #9aa4b2; --line: #2a2f3a;
    --bg: #0f1115; --surface: #171a21; --surface-2: #1d2129; --input-bg: #1d2129;
    --warn-bg: rgba(250, 204, 21, .12); --warn-text: #fcd34d;
    --ok-bg: rgba(16, 185, 129, .12); --ok-text: #6ee7b7; --ok-line: rgba(16, 185, 129, .3);
    --err-bg: rgba(239, 68, 68, .12); --err-text: #fca5a5; --err-line: rgba(239, 68, 68, .3);
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset; --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, .6);
}
@media (prefers-color-scheme: dark) {
    :root[data-mode="auto"] {
        color-scheme: dark;
        --text: #e8eaed; --muted: #9aa4b2; --line: #2a2f3a;
        --bg: #0f1115; --surface: #171a21; --surface-2: #1d2129; --input-bg: #1d2129;
        --warn-bg: rgba(250, 204, 21, .12); --warn-text: #fcd34d;
        --ok-bg: rgba(16, 185, 129, .12); --ok-text: #6ee7b7; --ok-line: rgba(16, 185, 129, .3);
        --err-bg: rgba(239, 68, 68, .12); --err-text: #fca5a5; --err-line: rgba(239, 68, 68, .3);
        --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset; --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, .6);
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font, "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif);
    color: var(--text); background: var(--bg);
    font-size: 15px; line-height: 1.65; letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { letter-spacing: -0.025em; line-height: 1.3; text-wrap: balance; font-family: var(--head-font, inherit); }
p { text-wrap: pretty; }
::selection { background: color-mix(in srgb, var(--primary) 22%, transparent); }
a { color: inherit; text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }
.container { max-width: var(--container, 1120px); margin: 0 auto; padding: 0 20px; }

/* 헤더: 스크롤해도 떠 있는 반투명 유리 */
.site-header { background: var(--header-bg); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); position: sticky; top: 0; z-index: 30; }
.header-inner { display: flex; align-items: center; gap: 28px; height: 64px; }
.logo { font-size: 20px; font-weight: 800; color: var(--text); white-space: nowrap; letter-spacing: -0.04em; }
.logo img { display: block; max-height: 36px; max-width: 200px; }
.gnb { flex: 1; }
.gnb .menu { list-style: none; display: flex; gap: 2px; margin: 0; padding: 0; }
.gnb .menu > li { position: relative; }
.gnb .menu > li > a { display: block; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 15px; color: color-mix(in srgb, var(--text) 80%, transparent); transition: background .15s var(--ease), color .15s var(--ease); }
.gnb .menu > li > a:hover { background: var(--surface-2); color: var(--text); }
.gnb .menu > li.active > a { background: var(--accent-soft); color: var(--primary); }
.gnb .submenu { position: absolute; top: calc(100% + 8px); left: 0; min-width: 180px; list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .15s var(--ease), transform .15s var(--ease), visibility .15s; }
.gnb .submenu::before { content: ''; position: absolute; inset: -10px 0 auto; height: 10px; }
.gnb .has-children:hover .submenu, .gnb .has-children:focus-within .submenu { opacity: 1; visibility: visible; transform: none; }
.gnb .submenu a { display: block; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.gnb .submenu a:hover { background: var(--surface-2); }
.gnb .submenu li.active a { color: var(--primary); }
.user-nav { display: flex; gap: 14px; align-items: center; font-size: 14px; white-space: nowrap; }
.user-name { color: var(--muted); }

.site-main { padding-top: 36px; padding-bottom: 72px; min-height: 70vh; }
.site-main.has-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.site-sidebar { display: grid; gap: 16px; position: sticky; top: 84px; }
.site-footer { border-top: 1px solid var(--line); padding: 32px 0; color: var(--muted); font-size: 13px; background: var(--surface); }
.footer-widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 28px; padding-bottom: 24px; margin-bottom: 20px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--text); }
.footer-text { white-space: normal; }
.home-widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 20px; }
.home-widgets .widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-sm); }

/* 위젯 공통 */
.site-sidebar .widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.widget-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.widget-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.widget-list li { display: flex; gap: 8px; padding: 7px 0; }
.widget-list li + li { border-top: 1px solid var(--line); }
.widget-list li a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-count { color: var(--primary); font-size: 12px; font-weight: 600; }
.widget-date, .widget-empty { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.widget-search { display: flex; gap: 6px; }
.widget-search .input { flex: 1; min-width: 0; }
.widget-login { display: grid; gap: 8px; }
.widget-register { font-size: 13px; color: var(--muted); text-align: center; }
.widget-user-links { display: flex; gap: 12px; margin-top: 10px; font-size: 13px; }
.widget-tags { display: flex; flex-wrap: wrap; gap: 6px; line-height: 1.6; }
.widget-tags a { color: var(--muted); padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px !important; }
.widget-tags a:hover { color: var(--primary); background: var(--accent-soft); }
.widget-text { font-size: 14px; }

/* 에디터로 쓴 본문 */
.rich-content { font-size: 16px; line-height: 1.8; }
.rich-content img { max-width: 100%; height: auto; border-radius: var(--radius); }
.rich-content blockquote { margin: 16px 0; padding: 12px 18px; border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted); }
.rich-content pre { background: #0f1115; color: #e8eaed; padding: 16px 18px; border-radius: var(--radius); overflow-x: auto; font-size: 14px; }
.rich-content .ql-align-center { text-align: center; }
.rich-content .ql-align-right { text-align: right; }
.rich-content .ql-align-justify { text-align: justify; }
.rich-content .ql-indent-1 { padding-left: 3em; }
.rich-content .ql-indent-2 { padding-left: 6em; }
.rich-content a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 24px; }
.tag-list a { font-size: 13px; font-weight: 500; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--primary); }

/* 공통 UI */
.inline { display: inline; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.link-button:hover { color: var(--primary); }
.flash { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok-text); border: 1px solid var(--ok-line); }
.flash-error { background: var(--err-bg); color: var(--err-text); border: 1px solid var(--err-line); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease); }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); border-color: transparent; color: var(--on-primary, #fff); box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--primary-dark); color: var(--on-primary, #fff); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err-line); color: var(--danger); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.input, textarea.input, select.input { width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid transparent; border-radius: var(--radius-sm); font: inherit; background: var(--input-bg); color: var(--text);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease); }
.input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input:hover { border-color: var(--line); }
.input:focus { outline: none; background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
.error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.muted { color: var(--muted); }

.auth-box { max-width: 420px; margin: 48px auto; padding: 36px; }
.auth-box h1 { margin-top: 0; font-size: 26px; }

/* 메인 최신글 */
.latest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.latest-box { transition: box-shadow .2s var(--ease), transform .2s var(--ease); }
.latest-box:hover { box-shadow: var(--shadow); }
.latest-box h2 { font-size: 17px; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; }
.latest-box h2 a.more { font-size: 13px; color: var(--muted); font-weight: 500; }
.latest-box ul { list-style: none; margin: 0; padding: 0; }
.latest-box li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; }
.latest-box li + li { border-top: 1px solid var(--line); }
.latest-box li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest-box .date { color: var(--muted); flex-shrink: 0; font-size: 13px; font-variant-numeric: tabular-nums; }

/* 페이지네이션 (Laravel bootstrap-5 마크업) */
.pagination { display: flex; justify-content: center; gap: 4px; list-style: none; padding: 0; margin: 28px 0 0; flex-wrap: wrap; }
.pagination .page-link { display: flex; align-items: center; justify-content: center; min-width: 38px; height: 38px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; transition: background .15s var(--ease); }
.pagination .page-link:hover { background: var(--surface-2); }
.pagination .active .page-link { background: var(--text); color: var(--surface); }
.pagination .disabled .page-link { color: var(--muted); opacity: .5; }
nav .d-sm-none, nav .small.text-muted { display: none; }
nav .d-none.d-sm-flex { display: block; }

@media (max-width: 900px) {
    .site-main.has-sidebar { grid-template-columns: 1fr; }
    .site-sidebar { position: static; }
}
@media (max-width: 760px) {
    .header-inner { flex-wrap: wrap; height: auto; gap: 8px 16px; padding-top: 12px; padding-bottom: 8px; }
    .gnb { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
    .gnb .menu > li > a { padding: 6px 12px; }
    .site-main { padding-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* 페이지·검색·태그·리비전 (코어 화면) */
.page-article { padding: 40px 48px; }
.page-title { font-size: 30px; font-weight: 800; margin: 0 0 24px; }
.page-edit { margin: 32px 0 0; text-align: right; }
.post-status-note { margin: 20px 0 0; padding: 12px 16px; background: var(--warn-bg); color: var(--warn-text); border-radius: var(--radius-sm); font-size: 14px; }
.search-form { display: flex; gap: 8px; margin-bottom: 24px; }
.result-heading { font-size: 16px; margin: 28px 0 8px; }
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li { padding: 16px 0; }
.result-list li + li { border-top: 1px solid var(--line); }
.result-list p { margin: 4px 0; font-size: 14px; color: var(--muted); }
.result-title { font-weight: 700; font-size: 17px; }
.result-meta { font-size: 13px; color: var(--muted); }
.revisions { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.revision-list h2 { font-size: 16px; margin: 0 0 10px; }
.revision-list ul { list-style: none; margin: 0; padding: 0; }
.revision-list li a { display: block; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.revision-list li.active a { background: var(--accent-soft); color: var(--primary); }
.revision-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
@media (max-width: 760px) { .revisions { grid-template-columns: 1fr; } .page-article { padding: 24px; } }

/* 페이지 템플릿 */
.page-wide .page-title { margin-top: 8px; }
.pb-preview-note { margin: 0 0 20px !important; }
.page-landing { background: var(--bg); }
.landing-main { padding-top: 0; padding-bottom: 48px; }
.landing-main > .pb-page > .pb:first-child.pb-bleed { margin-top: 0; }
.landing-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 16px 40px; }
