/* Pi node 정보실 — 공통 스타일 */
:root {
  --accent: #6b3fa0;
  --accent-strong: #563282;
  --bg: #f7f6fa;
  --surface: #ffffff;
  --text: #23202b;
  --text-muted: #6f6a7c;
  --border: #e4e1ec;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(35, 32, 43, 0.07);
}

/* 다크 테마 — 헤더의 토글 버튼으로 전환 (기본은 라이트) */
:root[data-theme="dark"] {
  --bg: #17151d;
  --surface: #201d29;
  --text: #eae7f1;
  --text-muted: #9d97ac;
  --border: #322e3f;
  --accent: #a980d6;
  --accent-strong: #c3a3e8;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 760px; margin: 0 auto; padding: 0 1rem; }

/* 헤더 */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.site-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.site-title:hover { text-decoration: none; }
.site-title .pi { color: var(--accent); }
.site-nav a { margin-left: 1rem; color: var(--text-muted); font-size: 0.95rem; }
.site-nav a:hover { color: var(--accent); }

/* 테마 전환 버튼 */
.theme-toggle {
  margin-left: 1rem;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  vertical-align: middle;
}
.theme-toggle:hover { border-color: var(--accent); }

main.container { padding-top: 1.5rem; padding-bottom: 3rem; }

/* 광고 슬롯: 광고 코드를 넣기 전까지는 점선 안내 상자로 표시됨 */
.ad-slot { margin: 1.25rem 0; text-align: center; }
.ad-slot:empty {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.ad-slot:empty::before { content: "광고 영역 (" attr(data-ad) ")"; }

/* 좌우 세로 광고 (윙 배너) — 넓은 화면에서만 표시, 애드센스 160x600 세로형에 맞는 크기 */
.ad-slot.side {
  position: fixed;
  top: 96px;
  width: 160px;
  margin: 0;
}
.ad-slot.side:empty { min-height: 600px; padding: 0.5rem; display: flex; align-items: center; justify-content: center; }
.ad-slot.side.left { left: calc(50% - 380px - 184px); }
.ad-slot.side.right { right: calc(50% - 380px - 184px); }
@media (max-width: 1180px) { .ad-slot.side { display: none; } }

/* 카테고리 탭 */
.category-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.category-tabs button {
  padding: 0.35rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
}
.category-tabs button:hover { border-color: var(--accent); color: var(--accent); }
.category-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 카테고리 배지 */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.55em;
  margin-right: 0.5em;
}

/* 게시글 목록 */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  transition: border-color 0.15s;
}
.post-card:hover { border-color: var(--accent); }
.post-card a { display: block; padding: 1.1rem 1.25rem; color: inherit; }
.post-card a:hover { text-decoration: none; }
.post-card h2 { margin: 0 0 0.35rem; font-size: 1.15rem; letter-spacing: -0.01em; }
.post-card .meta { font-size: 0.82rem; color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

/* 페이지네이션 */
.pagination { display: flex; justify-content: center; gap: 0.4rem; margin-top: 1.5rem; }
.pagination button {
  min-width: 2.2rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* 게시글 상세 */
.post-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.post-view h1.post-title { margin: 0 0 0.4rem; font-size: 1.6rem; letter-spacing: -0.02em; }
.post-view .meta { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.25rem; }
.post-body { word-break: break-word; overflow-wrap: anywhere; }
.post-body img { max-width: 100%; border-radius: 8px; }
.post-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.88rem;
}
.post-body code { font-family: Consolas, "D2Coding", monospace; font-size: 0.92em; }
.post-body p > code, .post-body li > code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.35em;
}
.post-body blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--bg);
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
}
.post-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.back-link { display: inline-block; margin-bottom: 1rem; font-size: 0.92rem; }

/* 푸터 */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--text-muted); text-decoration: underline; }

/* 폼 공통 */
.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea.editor { min-height: 320px; resize: vertical; line-height: 1.6; }

.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--accent-strong); }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }

.notice { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.notice.error { background: rgba(192, 57, 43, 0.1); color: var(--danger); }
.notice.success { background: rgba(107, 63, 160, 0.1); color: var(--accent); }
.hidden { display: none !important; }

/* 관리자 */
.admin-login {
  max-width: 380px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.admin-login h1 { margin-top: 0; font-size: 1.25rem; }

.admin-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.admin-toolbar h1 { margin: 0; font-size: 1.3rem; }
.admin-toolbar .actions { display: flex; gap: 0.5rem; }

.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
}
.admin-list .title { font-weight: 600; }
.admin-list .meta { font-size: 0.8rem; color: var(--text-muted); }
.admin-list .row-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.admin-list .row-actions button { font-size: 0.82rem; padding: 0.35rem 0.7rem; }

.editor-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.editor-toolbar button, .editor-toolbar .color-btn {
  min-width: 2rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.editor-toolbar button:hover, .editor-toolbar .color-btn:hover { border-color: var(--accent); color: var(--accent); }
.editor-toolbar .color-btn input[type="color"] {
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
.toolbar-sep { width: 1px; height: 1.4rem; background: var(--border); margin: 0 0.25rem; }

/* 위지윅 에디터 */
.rich-editor {
  min-height: 320px;
  max-height: 65vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.65;
}
.rich-editor:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.rich-editor:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.editor-toolbar button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.editor-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

@media (max-width: 600px) {
  .site-header .container { flex-direction: column; gap: 0.4rem; }
  .post-view { padding: 1.25rem; }
  .admin-list li { flex-direction: column; align-items: flex-start; }
}
