/* ─────────────────────────────────────────────────────────────
   CloudyMous Documents — 정보보안 문서 아카이브
   PDF 첫 페이지 썸네일 그리드 / 절제된 타이포 / 라이트·다크
   ───────────────────────────────────────────────────────────── */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard Variable",
    "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR",
    system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #ffffff;
  --bg-soft: #f6f6f7;
  --surface: #ffffff;
  --fg: #0b0b0c;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.15);
  --hover: rgba(0, 0, 0, 0.035);
  --accent: #2563eb;
  --brand-1: #3b82f6;
  --brand-2: #1e40af;
  --accent-soft: #eff6ff;
  --accent-line: #bfdbfe;
  --danger: #b91c1c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.10), 0 2px 6px -2px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b;
    --bg-soft: #141416;
    --surface: #141416;
    --fg: #f2f2f3;
    --muted: #9ca3af;
    --faint: #6b7280;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.18);
    --hover: rgba(255, 255, 255, 0.05);
    --accent: #60a5fa;
    --brand-1: #60a5fa;
    --brand-2: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.16);
    --accent-line: rgba(96, 165, 250, 0.35);
    --danger: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px -6px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0b;
  --bg-soft: #141416;
  --surface: #141416;
  --fg: #f2f2f3;
  --muted: #9ca3af;
  --faint: #6b7280;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --hover: rgba(255, 255, 255, 0.05);
  --accent: #60a5fa;
  --brand-1: #60a5fa;
  --brand-2: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.16);
  --accent-line: rgba(96, 165, 250, 0.35);
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px -6px rgba(0, 0, 0, 0.7);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -0.011em;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.wrap-narrow {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── 헤더 ─────────────────────────────────────────────── */

header.site {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  font-size: 0.9375rem;
  letter-spacing: -0.02em;
}

/* 헤더에 색이 하나도 없어 사이트가 무채색으로만 읽혔다. 브랜드 마크를 색 기준점으로 쓴다. */
.brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 7px;
  background: linear-gradient(140deg, var(--brand-1), var(--brand-2));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--brand-2) 40%, transparent);
}

nav.top {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

nav.top a,
nav.top button {
  padding: 0.3rem 0.55rem;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

nav.top a:hover,
nav.top button:hover { background: var(--hover); color: var(--fg); }

nav.top a.cta {
  color: var(--bg);
  background: var(--fg);
  font-weight: 550;
}

nav.top a.cta:hover { opacity: 0.85; color: var(--bg); }

/* ── 히어로 ───────────────────────────────────────────── */

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 3rem 0 1.75rem;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.hero .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.dot { color: var(--faint); margin: 0 0.4rem; }

/* 날짜 스테퍼 */
.datenav {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.datenav a,
.datenav span {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.datenav .cur {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 7.5rem;
  justify-content: center;
}

.datenav a:hover { background: var(--hover); color: var(--fg); }
.datenav .disabled { opacity: 0.3; pointer-events: none; }

/* 날짜 필터 칩 */
/* 흩어진 알약이 아니라 하나의 컨트롤로 읽히도록 묶는다 */
.datefilter {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin: 0 0 1.5rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  max-width: 100%;
}

.datefilter .chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.34rem 0.7rem;
  border-radius: 9px;
  background: transparent;
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.datefilter .chip:hover { color: var(--fg); background: var(--hover); }

.datefilter .chip.on {
  background: var(--surface);
  color: var(--fg);
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}

.datefilter .chip .n {
  font-size: 0.6875rem;
  padding: 0 0.3rem;
  border-radius: 9999px;
  background: var(--hover);
  color: var(--faint);
}

.datefilter .chip.on .n { background: var(--accent-soft); color: var(--accent); }

/* ── 카드 그리드 ──────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  padding-bottom: 4rem;
}

@media (max-width: 1000px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .grid { grid-template-columns: 1fr; gap: 1.25rem; } }

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* PDF 첫 페이지 썸네일 */
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;   /* 첫 페이지 상단(제목·초록)이 보이도록 */
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.card:hover .thumb img { transform: scale(1.025); }

.thumb .fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.4rem;
  color: var(--faint);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.thumb .fallback svg { width: 2rem; height: 2rem; opacity: 0.5; }

/* 썸네일 아래쪽이 글자 중간에서 뚝 끊기지 않도록 살짝 흐린다.
   PDF 지면이 흰색이라 흰색으로만 페이드해야 자연스럽다. 다크모드에서
   카드 배경색(어두움)으로 페이드하면 회색 얼룩처럼 보여서 쓰지 않는다. */
.thumb::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3rem;
  background: linear-gradient(to bottom, transparent, #fff);
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .thumb::after { display: none; }
}

:root[data-theme="dark"] .thumb::after { display: none; }

/* 카드 본문 */
.card-body {
  display: flex;
  gap: 0.85rem;
  padding: 1.05rem 1.15rem 1.15rem;
  flex: 1;
}

/* 추천 박스 */
.votebox {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  line-height: 1.1;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.votebox .caret { font-size: 0.6rem; color: var(--faint); margin-bottom: 0.1rem; }
.votebox .n {
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
}

.card:hover .votebox { border-color: var(--accent-line); }

.votebox.on { border-color: var(--accent-line); background: var(--accent-soft); }
.votebox.on .caret, .votebox.on .n { color: var(--accent); }

.card-main { min-width: 0; flex: 1; }

.card-title {
  margin: 0 0 0.55rem;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.03em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* 제목이 1줄이든 2줄이든 아래 메타행이 카드끼리 같은 높이에 오도록 */
  min-height: calc(2 * 1.4em);
}

.card:hover .card-title { color: var(--accent); }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  font-size: 0.75rem;
  color: var(--faint);
}

/* 출처 — 자료의 신뢰도를 좌우하므로 메타 중 유일하게 테두리를 준다 */
.card-meta .org {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  /* 출처가 길면 줄여서라도 날짜·쪽수·댓글이 같은 줄에 남게 한다 */
  min-width: 0;
  max-width: 10.5rem;
  padding: 0.16rem 0.5rem 0.16rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 9999px;
  background: var(--surface);
  color: var(--fg);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta .org svg { width: 12px; height: 12px; flex: none; color: var(--accent); }
.card-meta .when { font-variant-numeric: tabular-nums; }

.card-meta .icon-row {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-variant-numeric: tabular-nums;
}

/* 피드백이 달린 자료는 눈에 띄게 — 읽고 나서 의견을 남기라는 신호 */
.card-meta .cmt.has {
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.55rem;
}

.card-meta svg { width: 0.85rem; height: 0.85rem; opacity: 0.75; }

/* 태그 */
.tag {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--accent-line);
  border-radius: 9999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6875rem;
  line-height: 1.6;
  white-space: nowrap;
}

a.tag:hover { filter: brightness(0.96); }
:root[data-theme="dark"] a.tag:hover { filter: brightness(1.3); }

.tagrow { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ── 상세 페이지 ──────────────────────────────────────── */

.paper-head { padding: 2.5rem 0 1.5rem; }

.paper-head .kicker {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.6rem;
}

.paper-head h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.03em;
}

.paper-head .summary {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.8;
  max-width: 68ch;
}

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover { background: var(--hover); }
.btn svg { width: 0.95rem; height: 0.95rem; }

.btn.primary {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.btn.primary:hover { opacity: 0.86; background: var(--fg); }

.btn.voted {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--fg); }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }

/* PDF 뷰어 */
.viewer {
  margin: 0 0 3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: var(--shadow-sm);
}

.viewer object {
  display: block;
  width: 100%;
  height: min(85vh, 1000px);
  border: 0;
  background: var(--bg-soft);
}

.viewer-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1.5rem 2.5rem;
  text-align: center;
}

.viewer-fallback img {
  max-width: 320px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.viewer-fallback p { margin: 0; color: var(--muted); font-size: 0.875rem; }

.viewer-fallback-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

@media (max-width: 640px) {
  .viewer object { height: 60vh; }
}

/* ── 피드백 ───────────────────────────────────────────── */

.section-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0 0 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.section-title h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.section-title .n {
  font-size: 0.8125rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.comment-form { margin-bottom: 2rem; }

.field { margin-bottom: 0.6rem; }

.field label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { resize: vertical; min-height: 5.5rem; line-height: 1.7; }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

input::placeholder, textarea::placeholder { color: var(--faint); }

.form-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.form-row > * { flex: 1 1 12rem; }

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

.comment:last-child { border-bottom: 0; }

.comment-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
}

.comment-head .who { font-weight: 600; }
.comment-head .when { color: var(--faint); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.comment-head form { margin-left: auto; }

.comment-body {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.8;
  white-space: pre-wrap;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  border-radius: 50%;
  /* --h 는 닉네임에서 뽑은 고정 색상값. 같은 사람은 항상 같은 색으로 보인다. */
  background: hsl(var(--h, 220) 65% 92%);
  color: hsl(var(--h, 220) 55% 32%);
  border: 1px solid hsl(var(--h, 220) 50% 82%);
  font-size: 0.7rem;
  font-weight: 650;
  color: var(--muted);
}

/* ── 폼 페이지 (로그인 / 업로드) ──────────────────────── */

.panel {
  margin: 3rem 0 5rem;
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel h1 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.panel .hint {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.panel .field { margin-bottom: 1rem; }

.flash {
  margin: 1rem 0;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  border: 1px solid;
}

.flash.error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 7%, transparent);
}

/* ── 빈 상태 · 푸터 ───────────────────────────────────── */

.empty {
  padding: 5rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.empty .big { font-size: 1.05rem; font-weight: 600; color: var(--fg); margin-bottom: 0.4rem; }

footer.site {
  margin-top: 4rem;
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--faint);
}

footer.site .foot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   검색 · 정렬 · 페이지 이동
   ───────────────────────────────────────────────────────────── */

.searchbox {
  position: relative;
  flex: 1 1 auto;
  max-width: 22rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.searchbox svg {
  position: absolute;
  left: 0.625rem;
  width: 15px;
  height: 15px;
  color: var(--faint);
  pointer-events: none;
}

.searchbox input {
  width: 100%;
  height: 34px;
  padding: 0 0.75rem 0 2rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}

.searchbox input::placeholder { color: var(--faint); }

.searchbox input:focus {
  background: var(--surface);
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 검색창이 헤더를 밀어내지 않도록 좁은 화면에서는 접는다 */
@media (max-width: 640px) {
  .searchbox { max-width: none; margin: 0; }
  .searchbox input { font-size: 16px; }   /* iOS 가 16px 미만이면 확대해버린다 */
}

.sortbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.sortbar .sorts { display: inline-flex; gap: 0.25rem; }

.sortbar .sorts a {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}

.sortbar .sorts a:hover { background: var(--hover); color: var(--fg); }
.sortbar .sorts a.on { background: var(--bg-soft); color: var(--fg); font-weight: 600; }
.sortbar .count { color: var(--faint); font-variant-numeric: tabular-nums; }

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.3rem;
  margin: 2.5rem 0 0;
  font-size: 0.8125rem;
}

.pager a,
.pager span {
  min-width: 2rem;
  padding: 0.35rem 0.6rem;
  text-align: center;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pager a:hover { background: var(--hover); color: var(--fg); }

.pager span.on {
  background: var(--fg);
  color: var(--bg);
  font-weight: 600;
}

/* 키보드 사용자가 지금 어디에 있는지 항상 보이게 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─────────────────────────────────────────────────────────────
   모바일 · 인앱브라우저
   오픈채팅으로 유입되는 대부분이 카카오 인앱브라우저다.
   ───────────────────────────────────────────────────────────── */

/* 손가락으로 누르는 기기에서는 터치 타겟을 44px 이상으로.
   마우스 환경까지 키우면 데스크톱이 헐거워지므로 pointer:coarse 로 한정한다. */
@media (pointer: coarse) {
  .btn,
  nav.top a,
  nav.top button,
  .pager a,
  .pager span,
  .sortbar .sorts a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .datefilter .chip { min-height: 40px; }

  /* 태그는 촘촘한 게 정보 밀도상 맞아서, 크기 대신 누를 여백만 넓힌다 */
  .tag {
    position: relative;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
  }
  .tag::after {
    content: "";
    position: absolute;
    inset: -0.55rem -0.3rem;
  }

  .card-meta { gap: 0.45rem 0.6rem; }
}

/* PDF 미리보기 (모바일 전용) — <object> 인라인 렌더링이 안 되는 환경 대체 */
.preview {
  display: block;
  position: relative;
  margin: 1.25rem 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  text-decoration: none;
}

.preview img {
  display: block;
  width: 100%;
  height: auto;
  /* 첫 페이지 상단(제목·요약)이 보이도록 위쪽만 남기고 자른다 */
  max-height: 62vh;
  object-fit: cover;
  object-position: top center;
}

.preview-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 52px;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  font-size: 0.9375rem;
  font-weight: 600;
}

.preview-cta svg { width: 17px; height: 17px; }
.preview:active .preview-cta { background: var(--hover); }

/* 인앱브라우저 안내 */
.inapp {
  margin: 0.75rem 0 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.inapp-msg {
  margin: 0 0 0.7rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--fg);
}

.inapp-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.inapp-guide {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

.inapp-guide strong { color: var(--fg); }

/* 좁은 화면 헤더 — 검색창이 브랜드를 밀어내던 문제 */
@media (max-width: 560px) {
  .header-row {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    gap: 0.5rem 0.75rem;
  }

  .brand { order: 1; }
  nav.top { order: 2; margin-left: auto; }
  .searchbox { order: 3; flex: 1 0 100%; max-width: none; }

  .hero h1 { font-size: 1.6rem; }
}

/* 인앱브라우저는 주소창이 접혔다 펴지며 100vh 가 튄다 */
@supports (height: 100dvh) {
  body { min-height: 100dvh; }
}

/* 오픈채팅 유입은 첫 화면에서 자료가 바로 보여야 한다.
   좁은 화면에서 히어로·필터 여백을 줄이고 썸네일을 조금 낮춰 제목을 접힘선 위로 올린다. */
@media (max-width: 560px) {
  .hero { padding: 1.15rem 0 0.8rem; }
  .hero h1 { font-size: 1.45rem; }
  .hero .sub { font-size: 0.8125rem; }
  /* 세그먼트 컨트롤이 된 뒤로는 아래 패딩만 키우면 통이 비대칭이 된다.
     바깥 여백만 줄이고 안쪽 패딩은 건드리지 않는다. */
  .datefilter { margin-bottom: 0.8rem; }
  .rule { margin-bottom: 0.8rem; }
  .sortbar { margin-bottom: 0.7rem; }
  .thumb { aspect-ratio: 16 / 10; }
}

.rule {
  height: 1px;
  margin: 0 0 1.25rem;
  border: 0;
  background: var(--line);
}

/* 아카이브 현황 — 숫자가 있으면 "관리되고 있는 곳"으로 읽힌다 */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin-top: 0.85rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.stats b {
  color: var(--fg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 상세 페이지 상단 메타 — 카드와 같은 언어를 쓴다 */
.kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.kicker .org {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.55rem 0.16rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 9999px;
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
}

.kicker .org svg { width: 12px; height: 12px; color: var(--accent); }
.kicker .when { font-variant-numeric: tabular-nums; }
.kicker .sep { color: var(--faint); }

/* 다크모드에서는 파스텔 아바타가 너무 튄다 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .avatar {
    background: hsl(var(--h, 220) 45% 22%);
    color: hsl(var(--h, 220) 70% 78%);
    border-color: hsl(var(--h, 220) 40% 32%);
  }
}

:root[data-theme="dark"] .avatar {
  background: hsl(var(--h, 220) 45% 22%);
  color: hsl(var(--h, 220) 70% 78%);
  border-color: hsl(var(--h, 220) 40% 32%);
}

/* 좁은 화면에서 날짜 필터가 두 줄로 접히면 첫 카드가 접힘선 아래로 밀린다.
   한 줄로 두고 가로로 밀어 보게 한다. */
@media (max-width: 560px) {
  .datefilter {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
  }
  .datefilter::-webkit-scrollbar { display: none; }
  .datefilter .chip { flex: none; }
  .stats { gap: 0.3rem 0.9rem; margin-top: 0.7rem; font-size: 0.78rem; }
}

/* ─────────────────────────────────────────────────────────────
   연재 — 태그(주제 교차)와 다른 축. 순서와 진행 위치를 보여준다.
   ───────────────────────────────────────────────────────────── */

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.eyebrow a { color: var(--accent); font-weight: 650; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }

/* 카드 위의 연재 표시 */
.serieschip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  margin-bottom: 0.35rem;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6875rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.serieschip b { font-weight: 800; }
.serieschip:hover { text-decoration: underline; }

/* 연재 목록 */
.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
}

.series-card {
  display: flex;
  gap: 0.9rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.series-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.series-cover {
  position: relative;
  flex: none;
  width: 4.75rem;
  height: 6rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.series-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }

.series-count {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.15rem 0;
  text-align: center;
  background: color-mix(in srgb, var(--fg) 78%, transparent);
  color: var(--bg);
  font-size: 0.625rem;
  font-weight: 700;
}

.series-body { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }

.series-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--fg);
  line-height: 1.35;
}

.series-sum {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.series-latest { margin-top: auto; font-size: 0.75rem; color: var(--faint); }

/* 회차 목록 */
.epslist { list-style: none; margin: 0; padding: 0; }

.epslist li + li { border-top: 1px solid var(--line); }

.epslist a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 0.25rem;
  text-decoration: none;
  color: inherit;
}

.epslist a:hover { background: var(--hover); }

.epno {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.4rem;
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.epmain { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }
.eptitle { font-size: 0.9375rem; font-weight: 600; line-height: 1.4; }
.epmeta { font-size: 0.75rem; color: var(--faint); }

.epthumb {
  flex: none;
  width: 2.75rem;
  height: 3.5rem;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* 상세 페이지의 연재 이동 — 읽고 난 다음 행동이라 PDF 바로 아래에 둔다 */
.epnav { margin: 1.5rem 0 0; }

.epnav-next {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  text-decoration: none;
  min-height: 56px;
}

.epnav-next:hover { border-color: var(--accent); }
.epnav-label { flex: none; font-size: 0.75rem; font-weight: 700; color: var(--accent); }

.epnav-title {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
  font-weight: 650;
  color: var(--fg);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.epnav-arrow { flex: none; color: var(--accent); font-weight: 700; }

.epnav-end {
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

.epnav-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }

.eptoc { margin-top: 0.8rem; }

.eptoc summary {
  cursor: pointer;
  padding: 0.5rem 0;
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--muted);
}

.eptoc summary:hover { color: var(--fg); }

.eptoc ol { list-style: none; margin: 0.25rem 0 0; padding: 0; }

.eptoc li a,
.eptoc li > span {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.25rem;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--muted);
  line-height: 1.4;
}

.eptoc li a:hover { color: var(--fg); background: var(--hover); }
.eptoc li.on > span { color: var(--fg); font-weight: 650; }
.eptoc li.on .epno { background: var(--accent-soft); color: var(--accent); }

/* 태그가 겹치는 관련 자료 */
.related { margin-top: 2.5rem; }
.related-list { display: grid; gap: 0.5rem; }

.related-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  min-height: 56px;
}

.related-item:hover { background: var(--hover); border-color: var(--line-strong); }

.related-item img {
  flex: none;
  width: 2.25rem;
  height: 2.9rem;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.related-item > span { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.related-title { font-size: 0.875rem; font-weight: 600; line-height: 1.4; }
.related-date { font-size: 0.75rem; color: var(--faint); font-variant-numeric: tabular-nums; }

nav.top a.on { color: var(--fg); font-weight: 650; background: var(--hover); }

/* 워드마크 — CloudyMous 가 브랜드, Documents 는 종류를 나타내는 부제 */
.brand-name { display: inline-flex; align-items: baseline; gap: 0.3rem; }

.brand-sub {
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -0.01em;
}

/* 아주 좁은 화면에서만 브랜드만 남긴다. 360px 에서도 전체 워드마크가 들어간다
   (브랜드 222 + 내비 91 = 313px < 가용 328px). */
@media (max-width: 340px) {
  .brand-sub { display: none; }
}

/* 브랜드 이름이 길어 좁은 화면에서 내비가 다음 줄로 밀렸다(헤더 3줄).
   글자를 조금 줄여 브랜드와 내비를 한 줄에 유지한다 — 모바일 세로 공간이 아깝다. */
@media (max-width: 560px) {
  .brand { font-size: 0.8125rem; gap: 0.4rem; }
  .brand .mark { width: 1.5rem; height: 1.5rem; font-size: 0.65rem; }
  nav.top { gap: 0.15rem; }
  nav.top a, nav.top button { padding-left: 0.45rem; padding-right: 0.45rem; }
}
