:root {
  --bg: #ffffff;
  --text: #1f1f1f;
  --muted: #8a8a8a;
  --link: #1f1f1f;
  --border: #e4e4e4;
  --code-bg: #f4f4f4;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #161616;
  --text: #e6e6e6;
  --muted: #8f8f8f;
  --link: #e6e6e6;
  --border: #2e2e2e;
  --code-bg: #232323;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "IBM Plex Sans KR", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: break-word;
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
}

/* 영문 고정폭: 머리글, 메뉴, 부제, 날짜, 푸터 */
.mono {
  font-family: "JetBrains Mono", "IBM Plex Sans", "IBM Plex Sans KR", ui-monospace, "SF Mono", Menlo, monospace;
  word-break: normal;
}

/* 페이지(quotes 등)의 소제목과 quotes의 열 이름·날짜도 영문 고정폭 */
.page .content h2,
.page .content h3,
.page .content h4,
.quotes-head,
.content summary .date {
  font-family: "JetBrains Mono", "IBM Plex Sans", "IBM Plex Sans KR", ui-monospace, "SF Mono", Menlo, monospace;
  word-break: normal;
}

/* 제목 속 《》「」〈〉『』는 한쪽이 비어 있어 제목 줄이 들쭉날쭉해 보이므로 빈 쪽을 접는다 */
.bo { margin-left: -0.5em; }
.bc { margin-right: -0.5em; }

/* 머리글: 사이트 이름 + 소문자 메뉴 + 테마 토글 */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 3rem;
}

.site-title {
  font-weight: 700;
  text-decoration: none;
}

/* 메뉴와 토글은 한 덩어리로 줄바꿈해, 토글만 따로 떨어지는 폭이 없게 한다 */
.site-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.site-header nav {
  display: flex;
  gap: 1rem;
}

/* 좁은 화면: 덩어리를 풀어 첫 줄에 이름과 토글, 둘째 줄에 메뉴. 한 줄에 다 들어가는 폭(약 540px)보다 조금 넉넉히 잡아, 덩어리째 둘째 줄로 내려가는 어중간한 배치가 생기지 않게 한다 */
@media (max-width: 600px) {
  .site-menu {
    display: contents;
  }

  .site-header nav {
    order: 3;
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: 0.2rem 0.6rem;
    margin-left: 0;
    font-size: 0.85rem;
  }

  .theme-toggle {
    margin-left: auto;
  }
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: var(--text);
}

.theme-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

/* 글리프/이모지 대신 SVG 마스크로 그려서 OS와 무관하게 글자색(currentColor)을 따른다 */
.theme-toggle::before {
  content: "";
  display: block;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask: var(--theme-icon) center / contain no-repeat;
  mask: var(--theme-icon) center / contain no-repeat;
  --theme-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] .theme-toggle::before {
  --theme-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E");
}

/* 홈: 전체 글 목록 */
.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-list li {
  margin: 0.3rem 0;
}

.post-list time,
.date,
.dash {
  color: var(--muted);
}

.post-list time,
.dash {
  font-size: 0.9em;
}

.dash {
  margin: 0 0.15em;
}

.post-list a {
  text-decoration: none;
}

/* 홈 목록: 한 줄에 날짜 — 제목, 길면 제목 끝을 …로 줄인다 */
.archive li {
  display: flex;
  align-items: baseline;
  gap: 0 0.5em;
}

.archive time,
.archive .dash {
  flex: none;
}

.archive .dash {
  margin: 0;
}

.archive a {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.post-list a:hover {
  text-decoration: underline;
}

/* 글 본문 */
h1 {
  margin: 0 0 0.25rem;
  font-size: 1.6rem;
  line-height: 1.4;
}

.subtitle {
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.date {
  display: block;
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.content h2,
.content h3,
.content h4 {
  margin: 2em 0 0.5em;
  line-height: 1.4;
}

.content h2 { font-size: 1.3rem; }
.content h3 { font-size: 1.15rem; }
.content h4 { font-size: 1rem; }

/* about: 첫 줄만 본문보다 조금 크고 굵게 */
.page .lead {
  margin: 0 0 0.6em;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.5;
}

/* 페이지의 소제목은 고정폭이라 같은 크기에서도 커 보이므로 줄인다 */
.page .content h2 { font-size: 1.05rem; }
.page .content h3 { font-size: 1rem; }
.page .content h4 { font-size: 0.95rem; }

.content p,
.content ul,
.content ol {
  margin: 0 0 1.1em;
}

.content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* 링크 카드는 자기 틀이 모서리를 정한다 */
.content .link-card img {
  border-radius: 0;
}

.content figure {
  margin: 2.2em 0;
}

.content figure img {
  display: block;
}

.content figure video {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* 흰 바탕 화면 캡처용. 사진에는 쓰지 않는다(어두워져 색이 바랜다) */
.content img.screenshot {
  border: 1px solid var(--border);
}

:root[data-theme="dark"] .content img.screenshot {
  filter: brightness(0.8);
}

/* 그림 여러 장을 2열로 묶는다. 좁은 화면에서는 글자가 작아지니 1열.
   글자가 없는 사진을 "왼쪽/오른쪽"으로 견줄 때는 `keep-cols`를 더해 2열을 유지한다 */
.content .figure-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin: 2.2em 0;
}

.content .figure-grid figure {
  margin: 0;
}

@media (max-width: 600px) {
  .content .figure-grid:not(.keep-cols) {
    grid-template-columns: 1fr;
  }
}

/* 강조점. 한국어에는 이탤릭이 어울리지 않아 마크다운 *강조*(em)를 글자마다 위에 점을 찍는 한글 전통 강조 표기로 그린다.
   영어 이탤릭(책 제목 등)은 <em lang="en">…</em>로 써서 점 대신 기울임으로 둔다. */
.content em {
  font-style: normal;
  text-emphasis: filled dot;
  text-emphasis-position: over right;
}

.content em:lang(en) {
  font-style: italic;
  text-emphasis: none;
}

/* 스크립트(assets/js/emphasis-dots.js)가 글자마다 .em-ch로 감싸면, 그 글자 위에 배경 점을 그리고 text-emphasis는 끈다 */
.content em.em-dotted {
  text-emphasis: none;
}

/* 한글이 없는 강조(영문, 숫자만)는 점 대신 기울임 */
.content .em-lat {
  font-style: italic;
}

.content em.em-italic {
  font-style: italic;
  text-emphasis: none;
}

.content .em-ch {
  background-image: radial-gradient(circle at 50% 0.06em, currentColor 0.05em, transparent 0.062em);
  background-size: 100% 0.3em;
  background-repeat: no-repeat;
  background-position: left top;
}

/* 배경이 안 보이거나 인쇄되지 않을 수 있는 환경(인쇄, 고대비 모드)에서는 점 대신 기울임 */
@media print, (forced-colors: active) {
  .content em.em-dotted {
    font-style: italic;
  }

  .content .em-ch {
    background: none;
  }
}

/* 중요하지 않은 표지 몇 장을 한 줄에 작게 늘어놓는다 */
.content .cover-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

.content .cover-row img {
  height: 7rem;
  width: auto;
}

.content figcaption {
  margin-top: 0.4em;
  font-size: 0.85em;
  line-height: 1.5;
  color: var(--muted);
}

/* 한글에는 이탤릭이 어울리지 않아 쓰지 않는다 */
em,
i,
cite {
  font-style: normal;
}

blockquote {
  margin: 1.5em 0;
  padding: 0 0 0 1rem;
  border-left: 3px solid var(--border);
}

blockquote > :last-child {
  margin-bottom: 0;
}

/* quotes: 한 줄(출처)로 접어 두고, 누르면 인용문을 펼친다 */
.quotes-head {
  display: flex;
  justify-content: space-between;
  padding: 0 0 0.4rem 1.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.content details {
  border-bottom: 1px solid var(--border);
}

.content details:first-of-type {
  border-top: 1px solid var(--border);
}

.content summary {
  position: relative;
  padding: 0.7rem 0 0.7rem 1.2rem;
  cursor: pointer;
  list-style: none;
}

.content summary::-webkit-details-marker {
  display: none;
}

.content summary::before {
  content: "+";
  position: absolute;
  left: 0;
  color: var(--muted);
}

.content details[open] > summary::before {
  content: "−";
}

.content summary .date {
  float: right;
  margin: 0.15rem 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* 좁은 화면: 날짜를 제목 옆에서 빼 둘째 줄(글쓴이 줄) 오른쪽 끝으로 내려, 제목이 전체 폭을 쓰게 한다 */
@media (max-width: 520px) {
  .content summary .date {
    position: absolute;
    right: 0;
    bottom: 0.7rem;
    float: none;
    margin: 0;
  }
}

.content summary .by {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.content details blockquote {
  margin: 0.3rem 0 0.5rem;
}

.content .source {
  margin: 0 0 1.2rem;
  word-break: normal;
  text-align: right;
  color: var(--muted);
  font-size: 0.9rem;
}

/* 출처 줄 글꼴: 영문·쪽수만 있는 quotes는 고정폭, 한글이 들어가면 고정폭과 어울리지 않으니
   `{: .source .ko}`로 표시해 본문 글꼴을 쓴다. 글 본문의 출처 줄은 처음부터 본문 글꼴이다 */
.content details .source:not(.ko) {
  font-family: "JetBrains Mono", "IBM Plex Sans", "IBM Plex Sans KR", ui-monospace, "SF Mono", Menlo, monospace;
}

.content .source a {
  color: var(--muted);
}

/* 인용 아래 짧은 코멘트: 출처 줄에 붙여 한 덩어리로 보이게 한다 */
.content .source:has(+ .note) {
  margin-bottom: 0.6rem;
}

/* 이미지 아래 출처 줄: 오른쪽 정렬 대신 이미지에 붙여 캡션처럼 왼쪽에 둔다 */
.content figure:has(+ .source) {
  margin-bottom: 0.5rem;
}

.content figure + .source {
  text-align: left;
}

.content details .note {
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
}

hr {
  margin: 2.5em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

code {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--code-bg);
  font-size: 0.9em;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 4px;
  background: var(--code-bg);
  line-height: 1.5;
}

pre code {
  padding: 0;
  background: none;
}

/* 이전/다음 글 */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.post-nav a {
  color: var(--muted);
  text-decoration: none;
}

.post-nav a:hover {
  color: var(--text);
}

/* 댓글 */
.comments {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.comments-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 1rem;
}

.comments h2 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.like-btn[hidden] {
  display: none;
}

/* like → thanks! → liked 로 글자 길이가 달라져도 하트가 움직이지 않도록 오른쪽 정렬 칸을 고정한다. */
.like-label {
  min-width: 7ch;
  text-align: right;
  transition: opacity 0.12s ease;
}

.like-btn svg {
  position: relative;
  top: 1px;
}

/* 눌리기 전엔 가는 윤곽선, 누르면 굵은 선과 채움(둘 다 같은 회색)으로 구분한다. */
.like-btn path {
  fill: none;
  stroke-width: 1.2;
}

.like-btn[aria-pressed="true"] path {
  fill: currentColor;
  stroke-width: 1.8;
}

/* 눌리기 전에만 호버로 진해진다. 눌린 뒤에는 변하지 않아 두 상태가 갈린다. */
@media (hover: hover) {
  .like-btn[aria-pressed="false"]:hover {
    color: var(--text);
  }
}

@media (prefers-reduced-motion: reduce) {
  .like-label {
    transition: none;
  }
}

.comment-list {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.comment-list li {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.comment-list p {
  margin: 0.2rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-head {
  display: flex;
  gap: 0.8rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.comment-head a {
  color: inherit;
}

.comment-owner {
  padding: 0 0.35rem;
  border: 1px solid var(--border);
  color: var(--text);
}

.comment-reply-btn,
.comment-replying button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.comment-reply-btn:hover,
.comment-replying button:hover {
  color: var(--text);
}

.comment-replies {
  margin: 0.6rem 0 0 0.4rem;
  padding: 0 0 0 1rem;
  border-left: 3px solid var(--border);
  list-style: none;
}

.comment-replies > li {
  padding: 0.6rem 0 0;
  border-bottom: 0;
}

.comment-replying {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.comment-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.comment-form input[type="text"],
.comment-form textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

/* 이름과 웹사이트는 한 줄에 둔다(이름은 좁게, 웹사이트는 남는 폭). 아주 좁은 화면에서는 두 줄로 나뉜다. */
.comment-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.6rem;
}

.comment-fields .comment-name {
  flex: 1 1 9rem;
  min-width: 0;
}

.comment-fields .comment-website {
  flex: 2 1 12rem;
  min-width: 0;
}

.comment-form textarea {
  resize: vertical;
  /* 처음 크기(4줄)보다 작게 줄일 수 없고, 8줄(2배)까지만 늘릴 수 있다. 줄 높이 단위(lh)를 모르는 브라우저를 위해 rem 값을 먼저 둔다. */
  min-height: calc(7.65rem + 2px);
  max-height: calc(14.3rem + 2px);
  min-height: calc(4lh + 1rem + 2px);
  max-height: calc(8lh + 1rem + 2px);
}

.comment-form input:focus,
.comment-form textarea:focus {
  outline: none;
  border-color: var(--muted);
}

/* 봇이 채우는 숨은 칸 */
.comment-trap {
  position: absolute !important;
  left: -9999px;
}

/* 확인 상자(있을 때만 보임), 글자 수, post를 한 줄에 둔다. 좁은 화면에서는 글자 수와 post가 위, 확인 상자가 아래로 간다. */
.comment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0;
}

.comment-actions .comment-count {
  margin: 0 1rem 0 auto;
}

.comment-captcha:empty {
  display: none;
}

@media (max-width: 430px) {
  .comment-actions .comment-count,
  .comment-actions button {
    order: -1;
  }
}

/* 글자 수 표시: 한도의 90%에 가까워지면 글자색이 진해진다 */
.comment-count {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.comment-count.near {
  color: var(--text);
}

.comment-note,
.comment-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.comment-status {
  min-height: 1.2em;
  margin-top: 0.6rem;
}

.comment-form button {
  padding: 0.35rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: none;
  color: var(--text);
  font: inherit;
  /* 메뉴·제목과 같은 고정폭 글꼴(.mono와 같은 목록). 위의 font: inherit가 .mono를 덮어쓰기 때문에 여기서 다시 지정한다. */
  font-family: "JetBrains Mono", "IBM Plex Sans", "IBM Plex Sans KR", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9rem;
  cursor: pointer;
}

.comment-form button:hover:not(:disabled) {
  border-color: var(--muted);
}

.comment-form button:disabled {
  color: var(--muted);
  cursor: default;
}

/* 검색 */
.search-input {
  width: 100%;
  margin-bottom: 2rem;
  padding: 0.4rem 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: none;
  color: var(--text);
  font: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  border-bottom-color: var(--muted);
}

.search-results li {
  margin-bottom: 1rem;
}

.search-snippet,
.search-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

mark {
  background: var(--code-bg);
  color: var(--text);
}

/* 하단: 구분선 + 카피라이트 + rss */
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}


/* 링크 카드: 왼쪽 작은 썸네일 + 오른쪽 글 */
.link-card {
  display: flex;
  align-items: stretch;
  max-width: 38rem;
  margin: 1.25rem 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.link-card:hover {
  border-color: var(--muted);
}

.link-card img {
  flex: none;
  width: 6rem;
  object-fit: cover;
  border-right: 1px solid var(--border);
}

.link-card-body {
  display: block;
  min-width: 0;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.link-card-site {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.link-card-title {
  display: -webkit-box;
  overflow: hidden;
  font-weight: 700;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.link-card-desc {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (max-width: 30rem) {
  .link-card img {
    width: 4.5rem;
  }
}

/* quotes 쪽 이동 */
.pager {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.pager a {
  color: var(--muted);
  text-decoration: none;
}

.pager a:hover,
.pager [aria-current] {
  color: var(--text);
}

/* photos: 세로 사진이 많아 4:5로 잘라 격자로 보여 주고, 누르면 팝업으로 원본 비율로 연다 */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.photo-grid a {
  display: block;
}

.photo-grid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--code-bg);
  border-radius: 6px;
}

@media (max-width: 30rem) {
  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 각주 돌아가기 버튼(↩)이 iOS에서 이모지로 나오지 않도록 텍스트 글리프로 고정 */
.reversefootnote {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-variant-emoji: text;
}

/* 트윗 캡처처럼 글의 주장이 아닌 자료로 보여 줄 작은 스크린샷 */
.content img.tweet {
  max-width: 420px;
}

/* 인쇄: 테마와 상관없이 밝은 배경으로 찍고, 종이에서 쓸모없는 테마 토글은 숨긴다 */
@media print {
  :root,
  :root[data-theme="dark"] {
    --bg: #ffffff;
    --text: #1f1f1f;
    --muted: #8a8a8a;
    --link: #1f1f1f;
    --border: #e4e4e4;
    --code-bg: #f4f4f4;
    color-scheme: light;
  }

  :root[data-theme="dark"] .content img.screenshot {
    filter: none;
  }

  .theme-toggle {
    display: none;
  }
}
