/* 모서리 규칙: 이미지와 상세 창 14px, 입력과 버튼 10px, 태그와 작은 사이트 로고 6px */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #5f5f68;
  --line: #e4e4e7;
  --chip: #efeff1;
  --accent: #be123c;
  --on-accent: #ffffff;
  --r-media: 14px;
  --r-control: 10px;
  --r-tag: 6px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101012;
    --surface: #19191c;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --line: #2c2c31;
    --chip: #232327;
    --accent: #fb7185;
    --on-accent: #1a0509;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, system-ui, sans-serif;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* 작가 소개 */
.profile {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 32px;
  padding-bottom: 24px;
}
.avatar {
  flex: none;
  width: 84px;
  height: 84px;
  border-radius: var(--r-media);
  object-fit: cover;
  background: var(--chip);
}
.profile h1 {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.intro { margin: 6px 0 0; max-width: 56ch; white-space: pre-line; font-size: 15px; }
/* 소개 밑 배지: 링크 버튼보다 작고 조용하게 */
.author-badges { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.author-badges[hidden] { display: none; }
.author-badges li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
}
.badge-mark { flex: none; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; overflow: hidden; font-size: 10px; }
.badge-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.author-links { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; }
.author-links a {
  display: block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.author-links a:hover { border-color: var(--accent); color: var(--accent); }
.author-links a:active { transform: translateY(1px); }
.author-links a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 작가 페이지 링크: 사이트 로고를 정사각형 아이콘으로. PC에서는 오른쪽, 좁은 화면에서는 소개 아래.
   사이트가 많으면 여러 줄로 나뉘어요. 한 줄 칸 수(--cols)는 app.js가 줄마다 비슷하게 나뉘도록 정해요 */
.author-pages { flex: none; margin-left: auto; }
.author-pages[hidden] { display: none; }
.author-pages h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.site-icons { list-style: none; display: grid; grid-template-columns: repeat(var(--cols, 6), 40px); gap: 8px; margin: 0; padding: 0; }
.site-icons a {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--chip);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  overflow: hidden;
  transition: transform .25s var(--ease);
}
.site-icons img { width: 100%; height: 100%; object-fit: cover; display: block; }
.site-icons a:hover { transform: translateY(-2px); border-color: var(--accent); }
.site-icons a:active { transform: translateY(0); }
.site-icons a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 목록 위 도구: PC에서는 한 줄, 좁은 화면에서는 필터가 아랫줄로 내려가요.
   사이트는 버튼 하나로 접어 둬서, 사이트가 늘어도 이 줄은 길어지지 않아요 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.toolbar h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; }
.toolbar h2 span { margin-left: 4px; color: var(--muted); font-weight: 500; }
/* 검색 칸 바로 오른쪽에 정렬('필터') 버튼. 좁은 화면에서도 둘이 한 줄에 붙어 있어요 */
.search-row { position: relative; display: flex; align-items: center; gap: 8px; flex: 0 1 340px; min-width: 0; margin-left: auto; }
.search { flex: 1 1 auto; min-width: 0; }
#q {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
#q::placeholder { color: var(--muted); }
#q:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.filters button[aria-pressed="true"], .pick.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.filters button:focus-visible, .opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 사이트 고르기 버튼: '사이트' 다음에 지금 고른 곳(로고와 이름)이 보여요 */
.pick-key { color: var(--muted); }
.pick.on .pick-key { color: inherit; opacity: .72; }
.pick-name { font-weight: 700; }
.pick-mark {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--r-tag);
  background: var(--chip);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
}
.pick-mark[hidden] { display: none; }
.caret {
  width: 7px;
  height: 7px;
  margin: -4px 2px 0 3px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  transition: transform .25s var(--ease);
}
.pick[aria-expanded="true"] .caret { transform: translateY(4px) rotate(225deg); }

/* 정렬 버튼: '필터' 다음에 지금 고른 기준이 보이고, 누르면 아래에 기준 목록이 떠요 */
.sort { flex: none; }
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.sort-btn:hover, .sort-btn[aria-expanded="true"] { border-color: var(--text); }
.sort-btn:focus-visible, .sort-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sort-key { color: var(--muted); }
.sort-name { font-weight: 700; }
.sort-btn[aria-expanded="true"] .caret { transform: translateY(4px) rotate(225deg); }
.sort-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 148px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .14);
}
.sort-menu[hidden] { display: none; }
.sort-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-tag);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.sort-opt:hover { background: var(--chip); }
.sort-opt::before { content: ""; flex: none; width: 14px; text-align: center; font-size: 12px; color: var(--accent); }
.sort-opt[aria-checked="true"] { font-weight: 700; }
.sort-opt[aria-checked="true"]::before { content: "✓"; }

/* 19금 보기: 셋 중 하나를 고르는 붙은 버튼 */
.seg { display: flex; }
.seg button { position: relative; margin-left: -1px; border-radius: 0; }
.seg button:first-child { margin-left: 0; border-radius: var(--r-control) 0 0 var(--r-control); }
.seg button:last-child { border-radius: 0 var(--r-control) var(--r-control) 0; }
.seg button[aria-pressed="true"] { z-index: 1; }
.seg button:focus-visible { z-index: 2; }

/* 펼친 사이트 목록: 도구 줄 아래에 한 줄을 통째로 차지해요. 칸마다 로고, 이름, 캐릭터 수 */
.site-panel {
  order: 3;
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 6px;
}
.site-panel[hidden] { display: none; }
.opt {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.opt:hover { border-color: var(--text); }
.opt:active { transform: translateY(1px); }
.opt[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 700; }
.opt-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-tag);
  background: var(--chip);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}
.opt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-count { font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; opacity: .62; }
/* 지금 조건에서는 캐릭터가 없는 사이트 */
.opt.none:not([aria-pressed="true"]) > * { opacity: .45; }

/* 캐릭터 목록: PC는 한 줄에 5명, 휴대폰은 2명씩 */
.grid {
  list-style: none;
  margin: 0;
  padding: 0 0 80px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 28px 18px;
  align-items: start;
}
.card { position: relative; display: flex; flex-direction: column; gap: 10px; }
.thumb {
  aspect-ratio: 1 / 1;
  border-radius: var(--r-media);
  overflow: hidden;
  background: var(--chip);
  display: grid;
  place-items: center;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
  transition: transform .5s var(--ease);
}
.thumb .initial { font-size: 40px; font-weight: 700; color: var(--muted); }

/* 이미지 흐림: 흐린 동안에는 확대·마우스 효과가 있어도 그림이 드러나지 않아요 */
.thumb { position: relative; }

/* 독점 표시: 썸네일 왼쪽 아래 모서리 삼각형 */
.excl {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  width: var(--excl, 64px);
  height: var(--excl, 64px);
  background: var(--accent);
  clip-path: polygon(0 0, 0 100%, 100% 100%);
  pointer-events: none;
}
.excl b {
  position: absolute;
  left: 33%;
  top: 67%;
  transform: translate(-50%, -50%) rotate(45deg);
  color: #fff;
  font-size: calc(var(--excl, 64px) * .21);
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}
#detailBody .excl { --excl: 84px; }
@media (max-width: 480px) { .card .excl { --excl: 52px; } }
.thumb.veiled img { filter: blur(36px) saturate(.8) brightness(.75); transform: scale(1.25) !important; }
.veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, .2);
}
.veiled .veil { display: flex; }
.veil p { margin: 0; max-width: 18em; font-size: clamp(12px, 3.4vw, 14px); font-weight: 700; line-height: 1.4; word-break: keep-all; text-shadow: 0 1px 3px rgba(0, 0, 0, .45); }
.veil-show {
  padding: 6px 18px;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 999px;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.veil-show:hover { background: rgba(0, 0, 0, .55); }
.veil-show:focus-visible, .veil-hide:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.veil-hide {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  cursor: pointer;
}
.sensitive:not(.veiled) .veil-hide { display: grid; }
.card:hover .thumb img { transform: scale(1.03); }
.card:active .thumb img { transform: scale(1.01); }

.card-info { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.d-head { display: flex; align-items: center; gap: 8px; }
.card h3, .d-info h2 { min-width: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; letter-spacing: -0.01em; }
.card h3 { font-size: 16px; }
/* 이름 버튼 하나가 카드 전체를 덮어서, 카드 어디를 눌러도 상세가 열려요 */
.card-open {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.card-open::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-media); }
.card-open:focus-visible { outline: none; }
.card-open:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 4px; }
.card:hover .card-open { color: var(--accent); }

/* 찜하기 버튼. 카드 전체를 덮는 이름 버튼보다 위에 있어야 눌려요 */
.fav {
  position: relative;
  z-index: 3;
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.card > .fav { position: absolute; top: 8px; right: 8px; }
.fav:hover { color: var(--accent); }
.fav[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.fav:active { transform: scale(.94); }
.fav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.adult {
  flex: none;
  padding: 2px 6px;
  border-radius: var(--r-tag);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
/* 수상 표시: 19금 표시와 같은 모양, 색만 테두리로 */
.award {
  flex: none;
  padding: 1px 5px;
  border: 1px solid var(--accent);
  border-radius: var(--r-tag);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
/* 숨긴 카드 표시. 편집 화면에서만 보여요 */
.hidden-mark {
  flex: none;
  padding: 1px 5px;
  border-radius: var(--r-tag);
  background: var(--text);
  color: var(--bg, #fff);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
.desc { margin: 0; font-size: 13px; color: var(--muted); white-space: pre-line; }
/* 목록에서는 소개글 앞부분과 태그 두 줄까지만 보여요. 전체는 상세 창에 있어요 */
.card .desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 0; padding: 0; }
.tags li {
  padding: 1px 7px;
  border-radius: var(--r-tag);
  background: var(--chip);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 18px;
}
.card .tags { max-height: 45px; overflow: hidden; }

/* 사이트 로고. 카드 아래에서는 누르면 그 사이트의 캐릭터 페이지로 가요.
   카드 전체를 덮는 이름 버튼보다 위에 있어야 눌려요 */
.card-sites { list-style: none; display: flex; gap: 6px; margin: 4px 0 0; padding: 0; }
.card-sites a, .card-sites .off, .card-sites .more, .d-site-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--r-tag);
  background: var(--chip);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  overflow: hidden;
}
.card-sites img, .d-site-mark img, .pick-mark img, .opt-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-sites a { position: relative; z-index: 1; transition: transform .25s var(--ease); }
.card-sites a:hover { transform: translateY(-2px); border-color: var(--accent); }
.card-sites a:active { transform: translateY(0); }
.card-sites a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-sites .off { opacity: .45; }
/* 로고 자리가 모자랄 때 남은 사이트 수. 누르면 카드처럼 상세 창이 열려요 */
.card-sites .more { background: none; color: var(--muted); font-size: 12px; }

.grid:empty { padding-bottom: 0; }
.empty { margin: 0; padding: 40px 0 120px; color: var(--muted); }

/* 상세 창: PC에서는 왼쪽에 이미지와 사이트 링크가 붙어 있고, 오른쪽에 소개글이 길게 이어져요 */
.detail {
  width: min(960px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-media);
  background: var(--surface);
  color: var(--text);
  overscroll-behavior: contain;
}
.detail::backdrop { background: rgb(9 9 11 / .62); }
/* 닫기 버튼은 글을 아래로 내려도 창 위쪽에 붙어 있어요. 아래 여백을 버튼 높이만큼 당겨서 자리를 차지하지 않게 해요 */
.close {
  position: sticky;
  top: 12px;
  z-index: 2;
  display: block;
  height: 34px;
  margin: 12px 12px -46px auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.close:focus-visible, a.d-site:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#detailBody { display: grid; grid-template-columns: min(340px, 42%) minmax(0, 1fr); align-items: start; }
.d-side { position: sticky; top: 28px; display: flex; flex-direction: column; gap: 18px; min-width: 0; margin: 28px 0 28px 28px; }
#detailBody .thumb img { transition: none; }
.d-info { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 28px; }
.d-head { margin-right: 64px; }
.d-info h2 { flex: 1; font-size: 26px; letter-spacing: -0.02em; }
.d-text { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.d-text .desc { font-size: 14.5px; color: var(--text); }
.d-text .tags li { padding: 2px 8px; font-size: 12px; }
.d-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.d-text .d-label { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
/* 상세 소개글이 들어가는 틀. 높이는 app.js가 글 길이에 맞춰요 */
.d-frame { display: block; width: 100%; height: 160px; border: 0; }

/* 이동하기: 사이트마다 작은 칸 하나(로고와 이름). 한 곳이면 한 줄을 다 쓰고, 많아지면 한 줄에 세 칸씩 나란히 놓여요 */
.d-links { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.d-sites { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; margin: 0; padding: 0; }
.d-sites li { min-width: 0; container-type: inline-size; }
.d-site {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  color: var(--text);
  text-decoration: none;
}
.d-site-mark { flex: none; width: 26px; height: 26px; font-size: 12px; }
.d-site-name { min-width: 0; font-size: 13.5px; font-weight: 700; line-height: 1.25; }
a.d-site:hover { border-color: var(--accent); color: var(--accent); }
a.d-site:active { transform: translateY(1px); }
.d-site.off { opacity: .5; }
/* 칸이 넉넉할 때만 오른쪽에 화살표를 그려요 */
@container (min-width: 150px) {
  a.d-site::after {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin: 0 4px 0 auto;
    border: solid var(--accent);
    border-width: 2px 2px 0 0;
    transform: rotate(45deg);
  }
}
/* 사이트마다 다른 점: 칸 아래에 사이트 이름과 함께 모아 적어요 */
.d-sites + .d-label { margin-top: 6px; }
.d-notes { list-style: none; display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; font-size: 13px; color: var(--muted); }
.d-notes b { margin-right: 6px; color: var(--text); font-weight: 700; }

@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  /* 작가 페이지 링크가 소개 아래로 내려가요 */
  .profile { flex-wrap: wrap; }
  .profile-text { flex: 1; min-width: 0; }
  .author-pages { flex-basis: 100%; margin-left: 0; }
  .site-icons { grid-template-columns: repeat(auto-fill, 40px); }
}
/* 한 줄에 다 안 들어가는 너비부터는 두 줄로: 윗줄에 제목과 검색, 아랫줄에 필터 */
@media (max-width: 960px) {
  .search-row { flex: 1 1 220px; max-width: 420px; order: 1; }
  .filters { flex: 1 1 100%; order: 2; }
}
@media (max-width: 780px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .profile { gap: 14px; padding-top: 20px; padding-bottom: 20px; }
  .avatar { width: 64px; height: 64px; }
  /* 휴대폰에서는 검색 칸과 정렬 버튼이 한 줄을 통째로 써요(제목은 그 위) */
  .search-row { flex: 1 1 100%; max-width: none; }
  /* 필터 두 줄: 사이트 고르기와 찜한 것만, 그 아래 19금 보기 */
  .pick { flex: 1 1 auto; justify-content: flex-start; }
  .pick .caret { margin-left: auto; }
  .seg { flex: 1 1 100%; }
  .seg button { flex: 1; padding: 0 6px; }

  /* 휴대폰은 한 화면에 4명쯤 보이도록 글을 조금 더 줄여요 */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 12px; padding-bottom: 64px; }
  .card { gap: 8px; }
  .card h3 { font-size: 15px; }
  .card .desc { font-size: 12.5px; -webkit-line-clamp: 3; line-clamp: 3; }
  .card .tags { max-height: 20px; }
}
/* 좁은 화면의 상세 창은 한 줄로: 이미지, 이름, 사이트 링크, 소개글 순서 */
@media (max-width: 720px) {
  .detail { width: calc(100% - 24px); max-height: calc(100dvh - 32px); }
  #detailBody { display: flex; flex-direction: column; align-items: stretch; }
  .d-side, .d-info { display: contents; }
  #detailBody .thumb { order: 1; border-radius: 0; aspect-ratio: 4 / 3; }
  .d-head { order: 2; margin: 18px 20px 0; }
  .d-links { order: 3; margin: 14px 20px 0; }
  /* 좁은 화면에서도 한 줄에 세 칸이 들어가게 칸을 조금 줄여요 */
  .d-sites { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
  .d-site { gap: 6px; min-height: 36px; padding: 5px 8px 5px 5px; }
  .d-site-mark { width: 22px; height: 22px; font-size: 11px; }
  .d-text { order: 4; margin: 16px 20px 24px; }
  .d-info h2 { font-size: 22px; }
}

@media (prefers-reduced-motion: no-preference) {
  .grid.first .card { animation: rise .55s var(--ease) both; animation-delay: calc(var(--i) * 35ms); }
  .detail[open] { animation: pop .28s var(--ease); }
  .detail[open]::backdrop { animation: fade .28s ease-out; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }
