:root {
  --site-max: 820px;        /* 중앙 레이아웃 최대 너비 (균형감 있게 좁힘) */
  --wrap-padding: 28px;     /* 좌우 패딩 (헤더 타이틀과 본문 시작 정렬에 영향) */
  --content-width: 680px;   /* 본문 읽기 폭 (고정 읽기 칼럼) */
  --list-width: 820px;
  --color-text: #111111;
  --color-muted: #666666;
  --color-muted-2: #999999;
  --bg: #ffffff;
}

html, body, .site-root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  line-height: 1.7;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;

  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 중앙 컨테이너 */
.wrap {
  max-width: var(--site-max);
  margin: 0 auto;
  padding: 0 var(--wrap-padding);
  box-sizing: border-box;
}

/* Header */
.site-header {
  background: var(--bg);
  border-bottom: none;
  padding: 0;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-title {
  margin: 0;
  padding: 18px 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.site-title a {
  color: var(--color-text);
  text-decoration: none;
}
.site-nav {
  display: flex;
  gap: 24px;
  align-items: center;
}
.site-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  opacity: 0.95;
}
.site-nav a:hover { opacity: 1; }

/* Main 영역 */
.site-main { flex: 1 0 auto; padding: 28px 0 60px 0; }

/* 목록 */
.listing-content {
  width: 100%;
  max-width: var(--list-width);
  margin: 0 auto;
  padding: 6px 12px;
  text-align: left;
  box-sizing: border-box;
}

.listing-content h1,
.listing-content h2 {
  margin: 8px 0 18px 0;
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
}

ul.simple-list { list-style: none; padding-left: 0; margin: 0; }
ul.simple-list li { padding: 10px 0; border-bottom: none; }

/* 포스트 (중요: 중앙 정렬된 읽기 칼럼) */
.post-content {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;                /* 가운데 정렬 — 균형감 확보 */
  padding: 6px 18px 36px 18px;
  box-sizing: border-box;
  color: var(--color-text);
}

.post-content h1 {
  margin: 6px 0 18px 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
}
.post-content h2 {
  margin: 14px 0 12px 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}
.post-content p {
  margin: 0 0 1rem 0;
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1.8;
  letter-spacing: -0.01em;
}

.post-content > p:first-of-type {
  text-indent: 1.5em;
  margin-top: 0.25rem;
}

/* 링크 및 상호작용: outline/box-shadow 제거, opacity만 변화 */
a, .site-nav a, .listing-content a, .post-content a, button, .btn {
  -webkit-tap-highlight-color: transparent;
  transition: opacity 160ms ease, color 160ms ease;
  text-decoration: none;
  outline: none;
  box-shadow: none;
}

a:hover, a:active { opacity: 0.8; text-decoration: none; }

a:focus { outline: none; box-shadow: none; opacity: 0.9; }

/* 키보드 접근성 포커스 시 미세 표시 유지 */
a:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: 2px solid rgba(0,0,0,0.06);
  outline-offset: 4px;
  opacity: 0.95;
}

.post-content a:focus-visible, .listing-content a:focus-visible {
  outline: 2px solid rgba(0,0,0,0.06);
  outline-offset: 4px;
}

/* 이미지: 기본적으로 읽기 칼럼에 맞춰 가운데 정렬, 깔끔한 여백 */
.post-content img,
.listing-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto; /* 가운데 정렬 */
  border: none;
  box-shadow: none;
}

/* 이미지 캡션/메타 */
.post-meta {
  color: var(--color-muted);
  font-size: 0.92rem;
  margin-top: 0.4rem;
}

/* 코드 블록 */
.post-content pre {
  background: #111;
  color: #f5f5f5;
  padding: 12px;
  overflow: auto;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace;
  margin: 1rem 0;
}
.post-content code {
  background: #f3f3f3;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  color: var(--color-text);
}

/* Footer */
.site-footer {
  border-top: none;
  padding: 24px 0;
  color: var(--color-muted);
  font-size: 0.9rem;
  text-align: center;
  background: var(--bg);
}

/* ===== Gallery: centered, larger previews, snap + nav ===== */
.post-gallery {
  position: relative;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 12px 6px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  align-items: center;
  margin: 0 auto 1.25rem auto;
  max-width: var(--content-width); /* gallery constrained to content width and centered */
  box-sizing: border-box;
}

/* primary preview: make each item roughly content-width for balance */
.post-gallery .gallery-item {
  flex: 0 0 auto;
  width: min(100%, 72vw, var(--content-width));
  max-width: var(--content-width);
  scroll-snap-align: center;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
  transition: transform 220ms ease;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

/* Slight scale on hover for desktop */
.post-gallery .gallery-item:hover {
  transform: scale(1.02);
}

/* Single inline zoomable images (non-gallery) keep 80% but centered */
.zoomable {
  width: 80%;
  max-width: var(--content-width);
  height: auto;
  display: block;
  border-radius: 6px;
  margin: 0 auto 1rem auto;
  cursor: zoom-in;
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: none;
}

/* navigation arrows (appear on hover) */
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.gallery-nav .g-btn {
  pointer-events: auto;
  background: rgba(255,255,255,0.92);
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  cursor: pointer;
  font-size: 16px;
  color: #111;
  opacity: 0.0;
  transition: opacity 180ms ease, transform 180ms ease;
}
.post-gallery:hover .gallery-nav .g-btn,
.post-gallery:focus-within .gallery-nav .g-btn {
  opacity: 1;
}
.gallery-nav .g-btn:active { transform: scale(0.98); }
.gallery-nav.left { left: 8px; }
.gallery-nav.right { right: 8px; }

/* Lightbox overlay */
.lb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1400;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.lb-overlay.active { display: flex; }
.lb-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  cursor: zoom-out;
}
body.lb-open { overflow: hidden; }

/* responsive adjustments */
@media (max-width: 980px) {
  :root { --wrap-padding: 20px; }
  .listing-content, .post-content { max-width: 100%; padding: 6px 12px; }
  .site-main { padding: 20px 0 60px 0; }
  .post-gallery .gallery-item { width: min(86vw, 640px); }
}
@media (max-width: 640px) {
  .post-gallery .gallery-item { width: min(90vw, 520px); }
  .zoomable { width: 92%; max-width: 520px; }
  .site-nav { display: none; }
  .site-title { font-size: 1rem; padding: 12px 0; }
}

/* focus outlines */
a:focus, button:focus { outline: 2px solid rgba(0,0,0,0.06); outline-offset: 3px; }

/* Mini audio header button + footer player */
.mini-audio-toggle {
  background: transparent;
  border: none;
  font-size: 14px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mini-audio-toggle.playing { color: var(--color-muted); }

#mini-audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid rgba(0,0,0,0.04);
  background: var(--bg);
  color: var(--color-text);
  font-size: 0.95rem;
  box-sizing: border-box;
  position: sticky;
  bottom: 0;
  z-index: 100;
}
#mini-audio-player .wrap { display:flex; align-items:center; gap:12px; width:100%; padding:0; }
#mini-audio-player .meta { flex: 1 1 auto; min-width: 0; }
#mini-ap-title { font-weight:600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mini-ap-progress-wrap { flex: 0 1 300px; background: rgba(0,0,0,0.05); height:8px; border-radius:999px; position:relative; cursor:pointer; }
#mini-ap-progress { position:absolute; left:0; top:0; bottom:0; width:0%; background: rgba(0,0,0,0.85); border-radius:999px; }
#mini-ap-time { color: var(--color-muted); font-size:0.86rem; margin-left:8px; }

/* Player control buttons (prev/play/next) */
.mini-ap-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
#mini-ap-prev,
#mini-ap-play,
#mini-ap-next {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  color: var(--color-text);
  transition: opacity 160ms ease;
}
#mini-ap-prev:hover,
#mini-ap-play:hover,
#mini-ap-next:hover {
  opacity: 0.7;
}
#mini-ap-prev:focus-visible,
#mini-ap-play:focus-visible,
#mini-ap-next:focus-visible {
  outline: 2px solid rgba(0,0,0,0.1);
  outline-offset: 2px;
}

/* === Video layout: fixed-ish height, full width, keep aspect ratio ===
   - Uses modern aspect-ratio when available, with sensible max-height fallback.
   - Video will keep 16:9 ratio; adjust aspect-ratio if needed.
*/
.video-wrap {
  width: 100%;
  max-width: 100%;
  /* prefer aspect-ratio where supported */
  aspect-ratio: 16 / 9;
  /* ensure not taller than viewport-friendly size */
  max-height: 480px;
  /* allow a smaller height on mobile */
  height: auto;
  background: #000;
  display: block;
  position: relative;
  overflow: hidden;
  margin: 1rem 0;
}

/* Ensure video fills the wrapper and keeps its ratio */
.video-wrap .site-video {
  width: 100%;
  height: 100%;
  object-fit: contain; /* or cover if you prefer crop */
  display: block;
  background: #000;
  border-radius: 6px;
}

/* Responsive tweak: smaller max height on small screens */
@media (max-width: 640px) {
  .video-wrap { max-height: 320px; aspect-ratio: 16 / 9; }
}

/* === Post Navigation (Previous/Next) ===
   Simple navigation at the bottom of posts for going to previous/next posts.
*/
.post-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.post-nav-links {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.post-nav-prev,
.post-nav-next {
  display: flex;
  flex-direction: column;
  max-width: 45%;
  text-decoration: none;
  color: var(--color-text);
  padding: 0.75rem 0;
  transition: opacity 160ms ease;
}

.post-nav-prev:hover,
.post-nav-next:hover {
  opacity: 0.7;
}

.post-nav-next {
  text-align: right;
  margin-left: auto;
}

.post-nav-label {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.25rem;
}

.post-nav-title {
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 2.8em; /* Fallback: 2 lines × 1.4 line-height */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.post-nav-empty {
  display: none;
}

@media (max-width: 640px) {
  .post-nav-links {
    flex-direction: column;
    gap: 1rem;
  }
  
  .post-nav-prev,
  .post-nav-next {
    max-width: 100%;
    text-align: left;
  }
  
  .post-nav-next {
    margin-left: 0;
  }
}