/* 또우리 공통: 토큰(DESIGN.md), 다크 모드, 상단 메뉴, 버튼, 푸터 */
:root {
  --primary: #4E7254; --primary-hover: #3F5F45; --on-primary: #FFFFFF;
  --weak-bg: #E6EEE3; --weak-fg: #3F5F45;
  --canvas: #FBF9F4; --card: #FFFFFF; --surface: #F2EEE5;
  --fg: #1D211E; --body: #4C524D; --muted: #868C86; --border: #E6E2D8;
  --danger: #C2483A; --danger-weak: #FBEAE6; --today: #F6DB8C; --on-today: #1D211E;
  --band: #1D2A21; --note-bg: rgba(255, 255, 255, .95); --shadow: rgba(29, 33, 30, .28);
  --ring: #A9C2AB;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --fast: 160ms; --standard: 240ms; --reveal: 600ms;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #8DB892; --primary-hover: #A2C7A6; --on-primary: #0F1A12;
    --weak-bg: #233026; --weak-fg: #A9CDAE;
    --canvas: #111412; --card: #1C211D; --surface: #171B18;
    --fg: #ECEFEA; --body: #B8BFB7; --muted: #879087; --border: #2B322D;
    --danger: #F08A7E; --danger-weak: #3A2220; --today: #E6C76A; --on-today: #1D211E;
    --band: #0B0F0C; --note-bg: rgba(31, 37, 32, .94); --shadow: rgba(0, 0, 0, .55);
    --ring: #4E7254; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #8DB892; --primary-hover: #A2C7A6; --on-primary: #0F1A12;
  --weak-bg: #233026; --weak-fg: #A9CDAE;
  --canvas: #111412; --card: #1C211D; --surface: #171B18;
  --fg: #ECEFEA; --body: #B8BFB7; --muted: #879087; --border: #2B322D;
  --danger: #F08A7E; --danger-weak: #3A2220; --today: #E6C76A; --on-today: #1D211E;
  --band: #0B0F0C; --note-bg: rgba(31, 37, 32, .94); --shadow: rgba(0, 0, 0, .55);
  --ring: #4E7254; color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body { margin: 0; background: var(--canvas); color: var(--body); font-family: var(--font); font-size: 1.0625rem; line-height: 1.6; word-break: keep-all; -webkit-font-smoothing: antialiased; transition: background-color var(--standard) ease; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-radius: 10px; }
h1, h2, h3 { color: var(--fg); margin: 0; text-wrap: balance; font-weight: 700; }
.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 24px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 56px; padding: 0 28px; border-radius: 16px; background: var(--primary); color: var(--on-primary); font: 600 1.0625rem var(--font); text-decoration: none; border: 0; cursor: pointer; white-space: nowrap;
  transition: transform var(--fast) var(--ease-out), background-color var(--fast) ease; }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.sm { height: 40px; padding: 0 16px; border-radius: 10px; font-size: .9375rem; }
.btn.weak { background: var(--weak-bg); color: var(--weak-fg); }
.btn.ghost { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px var(--border); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--primary-hover); }
  .btn.weak:hover { background: var(--weak-bg); filter: brightness(.97); }
  .btn.ghost:hover { background: var(--surface); }
}

/* 상단 메뉴 */
.nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50; transition: background-color var(--standard) ease, box-shadow var(--standard) ease; }
.nav.scrolled, .nav.open { background: color-mix(in srgb, var(--canvas) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 1px 0 var(--border); }
.nav-in { display: flex; align-items: center; gap: 32px; height: 68px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.375rem; color: var(--primary); text-decoration: none; letter-spacing: -0.04em; }
.logo img { width: 28px; height: 28px; }
.menu { display: flex; gap: 4px; flex: 1; }
.menu a { padding: 8px 12px; border-radius: 10px; font-size: .9375rem; font-weight: 600; color: var(--body); text-decoration: none; transition: background-color var(--fast) ease, color var(--fast) ease; }
.menu a[aria-current] { color: var(--fg); }
.menu .m-only { display: none; }
@media (hover: hover) and (pointer: fine) { .menu a:hover { background: var(--surface); color: var(--fg); } }
.actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.actions .link { padding: 8px 12px; font-size: .9375rem; font-weight: 600; color: var(--body); text-decoration: none; border-radius: 10px; }
@media (hover: hover) and (pointer: fine) { .actions .link:hover { background: var(--surface); color: var(--fg); } }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--body); display: grid; place-items: center; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--surface); color: var(--fg); } }
.icon-btn svg { width: 20px; height: 20px; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: none; }
}
.menu-btn { display: none; }

@media (max-width: 900px) {
  .nav-in { gap: 8px; height: 60px; }
  .menu { display: none; position: absolute; left: 0; right: 0; top: 60px; flex-direction: column; gap: 0; padding: 8px 16px 20px; background: var(--canvas); box-shadow: 0 1px 0 var(--border), 0 20px 40px -24px var(--shadow); }
  .nav.open .menu { display: flex; }
  .menu a { padding: 14px 8px; font-size: 1.0625rem; border-radius: 0; border-bottom: 1px solid var(--border); }
  .menu .m-only { display: block; }
  .actions .link { display: none; }
  .menu-btn { display: grid; }
}

/* 푸터 */
.foot { border-top: 1px solid var(--border); padding-block: 48px 64px; color: var(--muted); font-size: .875rem; }
.foot-in { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.foot nav { display: flex; gap: 20px; flex-wrap: wrap; }
.foot nav a { text-decoration: none; color: var(--body); }
.foot .tag { margin-top: 8px; }
.foot .fine { flex-basis: 100%; font-size: .75rem; }

/* 스크롤 등장: JS가 켜졌을 때만 숨김 */
.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity var(--reveal) var(--ease-out), transform var(--reveal) var(--ease-out); transition-delay: calc(var(--i, 0) * 80ms); }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { transform: none; transition: opacity 200ms ease; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 블로그·커뮤니티·관리 화면 */
.page { max-width: 880px; padding-block: 56px 120px; }
.page-head { margin-bottom: 40px; }
.page-head h1 { font-size: clamp(1.875rem, 4vw, 2.5rem); letter-spacing: -0.03em; line-height: 1.3; }
.page-head p { margin: 12px 0 0; font-size: 1.125rem; }
.page-head.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.page-head.row .btn { flex: none; }
.page-head a:not(.btn):not(.back) { color: var(--primary); }
.back { display: inline-block; margin-bottom: 16px; font-size: .9375rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.back::before { content: "\2190  "; }
.empty-note { padding: 48px 0; color: var(--muted); font-size: 1.0625rem; }

.post-list, .board, .comments ul { list-style: none; margin: 0; padding: 0; }
.post-list li { border-top: 1px solid var(--border); }
.post-list a { display: block; padding: 28px 0; text-decoration: none; }
.post-list time { font-size: .875rem; color: var(--muted); }
.post-list h2 { font-size: 1.375rem; letter-spacing: -0.02em; margin-top: 6px; }
.post-list p { margin: 8px 0 0; }

.board li { border-top: 1px solid var(--border); }
.board li:last-child { border-bottom: 1px solid var(--border); }
.board a { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 18px 8px; text-decoration: none; }
.board b { flex: 1; min-width: 0; color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .meta { flex-basis: 100%; font-size: .875rem; color: var(--muted); }
.board .pinned { background: color-mix(in srgb, var(--weak-bg) 55%, transparent); }
@media (hover: hover) and (pointer: fine) { .board a:hover b, .post-list a:hover h2 { color: var(--primary); } }
.badge { display: inline-block; flex: none; padding: 2px 8px; border-radius: 6px; background: var(--primary); color: var(--on-primary); font-size: .75rem; font-weight: 700; }
.badge.muted { background: var(--surface); color: var(--muted); }
.pager { display: flex; justify-content: space-between; margin-top: 24px; }
.pager a { font-weight: 600; color: var(--primary); text-decoration: none; padding: 8px 0; }

.article { max-width: 720px; }
.article header { margin-bottom: 32px; }
.article h1 { font-size: clamp(1.75rem, 4vw, 2.375rem); letter-spacing: -0.03em; line-height: 1.35; margin-top: 8px; }
.article time { display: block; margin-top: 12px; font-size: .875rem; color: var(--muted); }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; font-size: .875rem; color: var(--muted); }
.byline b { color: var(--fg); font-weight: 600; }
.tools { margin-left: auto; display: flex; gap: 4px; }
.text-btn { border: 0; background: none; padding: 6px 8px; border-radius: 8px; font: 600 .875rem var(--font); color: var(--body); cursor: pointer; }
.text-btn.danger { color: var(--danger); }
@media (hover: hover) and (pointer: fine) { .text-btn:hover { background: var(--surface); } }
.plain { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--fg); font-size: 1.0625rem; line-height: 1.75; }
.draft-bar { background: var(--today); color: var(--on-today); padding: 12px 16px; border-radius: 12px; margin: 0 0 24px; font-weight: 600; }

.prose { color: var(--fg); font-size: 1.125rem; line-height: 1.8; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.5rem; letter-spacing: -0.02em; margin: 2em 0 .6em; }
.prose h3 { font-size: 1.25rem; margin: 1.6em 0 .5em; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table { margin: 0 0 1.2em; }
.prose a { color: var(--primary); }
.prose img { border-radius: 16px; margin: 1.6em 0; height: auto; }
.prose blockquote { padding: 4px 0 4px 20px; border-left: 3px solid var(--primary); color: var(--body); }
.prose code { background: var(--surface); padding: 2px 6px; border-radius: 6px; font-size: .9em; }
.prose pre { background: var(--surface); padding: 16px; border-radius: 12px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: 8px 12px; text-align: left; }

.post-cta { max-width: 720px; margin-top: 72px; padding: 40px; border-radius: 24px; background: var(--band); color: #E9EFE8; }
.post-cta h2 { color: #fff; font-size: 1.5rem; }
.post-cta p { margin: 8px 0 24px; }

.comments { max-width: 720px; margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--border); }
.comments h2 { font-size: 1.125rem; margin-bottom: 8px; }
.comments li { padding: 16px 0; border-bottom: 1px solid var(--border); }
.comments li .byline { margin: 0 0 6px; }
.comments li .text-btn { margin-left: auto; }
.comments .form { margin-top: 20px; }
.login-note { margin-top: 20px; color: var(--muted); }
.login-note a { color: var(--primary); font-weight: 600; }

/* 입력 폼 */
.form { display: grid; gap: 20px; max-width: 720px; }
.form .f { display: grid; gap: 8px; font-weight: 600; color: var(--fg); }
.form .f small { font-weight: 400; color: var(--muted); }
.form input[type=text], .form textarea { width: 100%; font: 400 1.0625rem/1.6 var(--font); color: var(--fg); background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; resize: vertical; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.form .check { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--fg); }
.form .check input { width: 20px; height: 20px; accent-color: var(--primary); }
.form .hint { margin: 0; font-size: .875rem; color: var(--muted); }
.form-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.form-foot .msg { margin: 0; font-size: .9375rem; color: var(--body); }
.form-foot .msg a { color: var(--primary); }
#post-form .msg, #comment-form .msg { color: var(--danger); }
.slug { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--card); padding-left: 14px; }
.slug > span { color: var(--muted); font-weight: 400; white-space: nowrap; }
.form .slug input { border: 0; padding-left: 2px; background: transparent; }
.form .slug:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.form .slug input:focus { box-shadow: none; }

/* 관리: 넓은 화면에서는 쓰기 + 미리보기 나란히 */
.page:has(.editor) { max-width: 1200px; }
.editor { max-width: none; grid-template-columns: minmax(0, 1fr); }
.preview { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; min-height: 240px; }
.preview-h { font-size: .8125rem; font-weight: 700; color: var(--muted); margin-bottom: 16px; }
.form-foot.sticky { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--canvas); box-shadow: 0 -1px 0 var(--border); }
@media (min-width: 1000px) {
  .editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; column-gap: 32px; }
  .preview { position: sticky; top: 84px; max-height: calc(100vh - 180px); overflow: auto; }
  .form-foot.sticky { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .page { padding-block: 32px 96px; }
  .page-head.row { flex-direction: column; align-items: stretch; }
  .post-cta { padding: 28px 24px; }
}
.admin-gate { max-width: 420px; margin: 40px auto 0; }
.admin-gate h1 { font-size: 1.75rem; letter-spacing: -0.03em; }
.admin-gate > p { margin: 8px 0 28px; }
.admin-gate .form input[type=email], .admin-gate .form input[type=password] { width: 100%; font: 400 1.0625rem/1.6 var(--font); color: var(--fg); background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.admin-gate .form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.admin-gate .form .btn { width: 100%; }
.admin-gate .msg { color: var(--danger); }
