/* =========================================================
   레이아웃 — 미니멀한 티스토리 스킨 느낌 (흰 바탕, 좁은 본문, 넓은 여백)
   색상 변수는 entry.css 에 있습니다.
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.container { max-width: 760px; margin: 0 auto; padding: 48px 20px 80px; }
.container.narrow { max-width: 440px; }
.container.wide { max-width: 1000px; padding-top: 28px; }

/* ---------- 헤더 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.logo {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--text-strong);
  white-space: nowrap;
}
.gnb { display: flex; gap: 22px; flex: 1; min-width: 0; }
.gnb a {
  text-decoration: none;
  color: var(--sub);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.gnb a:hover { color: var(--text-strong); }
.gnb a.on { color: var(--text-strong); font-weight: 700; border-bottom-color: var(--text-strong); }

.tools { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: none;
  color: var(--sub);
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft); color: var(--text-strong); }
.btn-write {
  margin-left: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  background: var(--text-strong);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.search-bar { border-top: 1px solid var(--line); }
.search-bar input {
  display: block;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 20px;
  border: 0;
  background: transparent;
  font-size: 16px;
  outline: none;
}

/* ---------- 목록 ---------- */
.list-head { display: flex; align-items: baseline; gap: 10px; padding-bottom: 18px; border-bottom: 2px solid var(--text-strong); }
.list-head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.03em; color: var(--text-strong); }
.list-head .count { color: var(--accent); font-weight: 700; font-size: 15px; }

.post-list { list-style: none; margin: 0; padding: 0; }
.post-item { border-bottom: 1px solid var(--line); }
.item-link {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 30px 0;
  text-decoration: none;
  color: inherit;
}
.item-link .txt { flex: 1; min-width: 0; }
.item-link .cat { font-size: 13px; font-weight: 600; color: var(--accent); }
.item-link .title {
  margin: 6px 0 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}
.item-link:hover .title { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.item-link .ex {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.item-link .meta { font-size: 13px; color: var(--sub); }
.item-link .thumb {
  flex: none;
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--soft);
}
.lock { margin-right: 4px; font-size: .85em; }
.empty { padding: 80px 0; text-align: center; color: var(--sub); }
.empty a { color: var(--accent); }

.paging { display: flex; justify-content: center; gap: 4px; margin-top: 48px; flex-wrap: wrap; }
.paging a {
  min-width: 36px; height: 36px;
  padding: 0 8px;
  display: grid; place-items: center;
  border-radius: 18px;
  text-decoration: none;
  color: var(--sub);
  font-size: 14px;
}
.paging a:hover { background: var(--soft); }
.paging a.on { background: var(--text-strong); color: var(--bg); font-weight: 700; }

/* ---------- 글 보기 ---------- */
.post-head { padding-bottom: 28px; margin-bottom: 40px; border-bottom: 1px solid var(--line); }
.post-head .cat { font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; }
.post-title {
  margin: 10px 0 14px;
  font-size: 32px;
  line-height: 1.4;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--text-strong);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.post-meta { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--sub); flex-wrap: wrap; }
.admin-links { display: inline-flex; gap: 10px; align-items: center; }
.admin-links form { display: inline; margin: 0; }
.admin-links a, .link-btn { color: var(--sub); text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; font-size: 14px; }
.admin-links a:hover, .link-btn:hover { color: var(--text-strong); text-decoration: underline; }

.game-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px 20px;
  margin: 0 0 40px;
  padding: 20px 22px;
  border-radius: 10px;
  background: var(--soft);
}
.game-card div { min-width: 0; }
.game-card dt { font-size: 12px; color: var(--sub); margin-bottom: 2px; }
.game-card dd { margin: 0; font-weight: 600; color: var(--text-strong); overflow-wrap: anywhere; }
.game-card dd a { text-decoration: none; border-bottom: 1px solid currentColor; }
.game-card .stars { color: #f4a62a; letter-spacing: 1px; }

.post-nav { margin-top: 72px; border-top: 1px solid var(--line); }
.post-nav a {
  display: block;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-nav a span { display: inline-block; width: 72px; color: var(--sub); font-size: 13px; font-weight: 400; }
.post-nav a:hover { color: var(--text-strong); }
.back { margin-top: 28px; font-size: 14px; }
.back a { color: var(--sub); text-decoration: none; }

/* ---------- 라이트박스 ---------- */
.lightbox {
  position: fixed; inset: 0;
  z-index: 1000;
  display: none;
  background: rgba(0, 0, 0, .92);
  color: #fff;
}
.lightbox.open { display: block; }
.lb-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 48px 56px; overflow: auto; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 96px); object-fit: contain; cursor: zoom-in; }
.lightbox.zoomed .lb-stage { display: block; padding: 0; }
.lightbox.zoomed .lb-stage img { max-width: none; max-height: none; cursor: zoom-out; }
.lightbox button {
  position: absolute;
  z-index: 2;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  width: 46px; height: 46px;
  border-radius: 50%;
  cursor: pointer;
}
.lightbox button:hover { background: rgba(255, 255, 255, .25); }
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lightbox.single .lb-prev, .lightbox.single .lb-next, .lightbox.zoomed .lb-prev, .lightbox.zoomed .lb-next { display: none; }
.lb-count { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 13px; opacity: .8; }

/* ---------- 폼 공통 ---------- */
.form-page h1 { font-size: 24px; margin: 0 0 24px; color: var(--text-strong); }
.stack { display: grid; gap: 16px; }
.stack label { display: grid; gap: 6px; font-size: 14px; color: var(--sub); }
input[type=text], input[type=password], input[type=search], input[type=datetime-local], select, textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  padding: 10px 12px;
  font-size: 15px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--text-strong); outline-offset: -1px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 42px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--text-strong); border-color: var(--text-strong); color: var(--bg); }
.error { background: #fdecea; color: #b3261e; padding: 10px 14px; border-radius: 6px; font-size: 14px; }
.notice { background: var(--soft); padding: 14px 16px; border-radius: 6px; line-height: 1.7; }
.checklist { padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; margin: 0 0 24px; }
.checklist li::before { content: "• "; color: var(--sub); }
.checklist li.ok::before { content: "✓ "; color: #1a8f4c; }
.checklist li.ng::before { content: "✕ "; color: #b3261e; }

/* ---------- 글쓰기 ---------- */
.write-top { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.write-top select { flex: none; }
.title-input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  border-bottom: 1px solid var(--line) !important;
  border-radius: 0 !important;
  padding: 10px 4px !important;
  font-size: 26px !important;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: transparent !important;
}
.title-input:focus { outline: none; border-bottom-color: var(--text-strong) !important; }

.game-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1.4fr 1fr;
  gap: 12px;
  margin: 0 0 16px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.game-fields legend { padding: 0 6px; font-size: 13px; font-weight: 700; color: var(--accent); }
.game-fields label { display: grid; gap: 4px; font-size: 12px; color: var(--sub); min-width: 0; }
.game-fields input, .game-fields select { width: 100%; padding: 8px 10px; font-size: 14px; }

.editor-tabs { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); }
.editor-tabs button {
  border: 0;
  background: none;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.editor-tabs button.on { color: var(--text-strong); font-weight: 700; border-bottom-color: var(--text-strong); }
.tab-help { margin-left: auto; font-size: 12px; color: var(--sub); }
.editor-wrap { margin-top: 10px; }
.editor-wrap .tox-tinymce { border-radius: 8px; border-color: var(--line); }
.html-source {
  width: 100%;
  min-height: 70vh;
  font-family: Consolas, "D2Coding", monospace;
  font-size: 14px;
  line-height: 1.6;
  tab-size: 2;
  white-space: pre-wrap;
  resize: vertical;
}

.write-bar {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 12px 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.write-bar .opts { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--sub); }
.write-bar .opts label { display: inline-flex; gap: 6px; align-items: center; }
.write-bar .opts select, .write-bar .opts input { padding: 6px 8px; font-size: 13px; }
.write-bar .actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.upload-status { font-size: 13px; color: var(--accent); }
.page-write .site-footer { display: none; }

/* ---------- 푸터 ---------- */
.site-footer { border-top: 1px solid var(--line); }
.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--sub);
}
.footer-inner a { color: var(--sub); text-decoration: none; }

/* ---------- 모바일 ---------- */
@media (max-width: 760px) {
  .header-inner { height: auto; flex-wrap: wrap; gap: 0 12px; padding: 10px 16px 0; }
  .logo { flex: 1; font-size: 18px; }
  .gnb {
    order: 3;
    flex-basis: 100%;
    gap: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 6px 0 0;
  }
  .gnb::-webkit-scrollbar { display: none; }
  .gnb a { padding: 6px 0 10px; }

  .container { padding: 32px 16px 60px; }
  .container.wide { padding-top: 16px; }

  .item-link { gap: 16px; padding: 22px 0; }
  .item-link .title { font-size: 17px; margin: 4px 0 6px; }
  .item-link .ex { font-size: 14px; margin-bottom: 6px; }
  .item-link .thumb { width: 92px; height: 92px; }

  .post-head { margin-bottom: 28px; padding-bottom: 20px; }
  .post-title { font-size: 25px; }
  .game-card { padding: 16px; margin-bottom: 28px; }
  .lb-stage { padding: 48px 0; }

  .write-top { flex-direction: column; align-items: stretch; }
  .title-input { font-size: 21px !important; }
  .game-fields { grid-template-columns: 1fr 1fr; }
  .tab-help { display: none; }
  .write-bar .actions { width: 100%; }
  .write-bar .actions .btn { flex: 1; }
}

/* ---------- 제목 옆 소개 메뉴 ---------- */
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.profile-link {
  font-size: 14px; font-weight: 500; color: var(--sub); text-decoration: none; white-space: nowrap;
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 14px;
}
.profile-link:hover, .profile-link.on { color: var(--text-strong); border-color: var(--text-strong); }
.post.profile .post-head { margin-bottom: 28px; }
.hint { font-size: 13px; color: var(--sub); margin: 0; line-height: 1.6; }
.page-heading { font-size: 20px; margin: 0; color: var(--text-strong); }

/* ---------- 설정 ---------- */
.container.narrow:has(.settings-page) { max-width: 640px; }
.set-group { display: grid; gap: 14px; padding: 22px 0; border-top: 1px solid var(--line); }
.set-group h2 { font-size: 17px; margin: 0; color: var(--text-strong); }
.stack label small { font-size: 12px; color: var(--sub); font-weight: 400; }
.stack label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.settings-page .actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.cat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cat-row {
  display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.cat-row .cat-name { min-width: 0; width: 100%; }
.cat-row .check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); white-space: nowrap; }
.cat-count { font-size: 12px; color: var(--sub); white-space: nowrap; }
.cat-move { display: flex; flex-direction: column; }
.icon-btn.sm { width: 24px; height: 18px; border-radius: 4px; font-size: 10px; }
.icon-btn:disabled { opacity: .25; cursor: default; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.danger { color: #b3261e; }
.btn:disabled { opacity: .4; cursor: default; }

@media (max-width: 760px) {
  .brand { flex: 1; }
  .brand .logo { flex: none; }
  .profile-link { font-size: 13px; padding: 2px 8px; }
  .cat-row { grid-template-columns: auto 1fr auto; grid-template-areas: "move name del" "move game count"; row-gap: 6px; }
  .cat-move { grid-area: move; }
  .cat-row .cat-name { grid-area: name; }
  .cat-row .check { grid-area: game; }
  .cat-count { grid-area: count; text-align: right; }
  .cat-row [data-act=del] { grid-area: del; }
}
