/* 카오모지 복사 */

/* 헤더와 폭을 맞춰 긴 목록을 넓게 탐색한다. 모바일 여백은 공통 규칙을 따른다. */
main {
  max-width: 1180px;
}

.subtitle {
  max-width: 800px;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* 추천 도구의 긴 설명이 작은 화면의 그리드 너비를 밀어내지 않게 한다. */
main .related-card {
  min-width: 0;
}

.km {
  margin-top: 0.4rem;
}

/* ── 검색 + 갈래 칩 (헤더 아래 고정) ── */
.km-bar {
  position: sticky;
  top: var(--header-h, 56px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem 0;
  margin-bottom: 0.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.km-search {
  position: relative;
  display: flex;
  align-items: center;
}
.km-search-ico {
  position: absolute;
  left: 0.85rem;
  color: var(--text-sub);
  pointer-events: none;
}
.km-search input {
  width: 100%;
  height: 44px;
  padding: 0 2.4rem 0 2.5rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.km-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
/* 사파리·크롬이 붙이는 기본 x 버튼 — 우리 버튼과 겹쳐서 숨긴다 */
.km-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.km-reset {
  position: absolute;
  right: 0.5rem;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text-sub);
  background: var(--chip);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.km-reset:hover { color: var(--text); }

.km-chips {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  scrollbar-width: thin;
}
.km-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 0.75rem;
  font-size: 0.83rem;
  font-family: inherit;
  color: var(--text-sub);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.km-chip:hover { color: var(--text); border-color: var(--primary); }
.km-chip.is-on {
  color: #fff;
  background: var(--primary-solid);
  border-color: var(--primary-solid);
}
.km-chip-ico { display: flex; line-height: 0; }
.km-chip-n {
  font-size: 0.72rem;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.km-hint {
  margin: 0.7rem 0 1rem;
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* ── 갈래 섹션 ── */
.km-sec { margin-bottom: 1.6rem; }
.km-sec[hidden] { display: none; }

.km-sec-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.km-sec-head h2 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.km-sec-ico { display: flex; line-height: 0; }
.km-sec-n {
  font-size: 0.75rem;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

/* 폭이 제각각인 콘텐츠라 격자 대신 흘려 배치한다.
   짧은 것은 min-width로 받쳐주고, 긴 것은 잘리지 않게 스스로 넓어진다. */
.km-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.km-item {
  position: relative;
  flex: 1 0 auto;
  min-width: 118px;
  max-width: 320px;
  min-height: 52px;
  padding: 0.6rem 0.8rem;
  /* 카오모지는 한·일 글꼴과 기호 영역을 넘나든다 — 폭넓게 폴백을 깐다 */
  font-family: "Apple SD Gothic Neo", "Hiragino Sans", "Yu Gothic", Meiryo,
    "Malgun Gothic", "Noto Sans KR", "Noto Sans JP", "Segoe UI Symbol", sans-serif;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  /* ♥ ✧ 같은 글자가 기기에 따라 컬러 이모지로 튀는 것을 막는다 */
  font-variant-emoji: text;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}
.km-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.km-item:active { transform: translateY(0); }

.km-item.is-copied {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 8%, var(--surface));
}
.km-item.is-copied::after {
  content: "✓";
  position: absolute;
  top: 3px;
  right: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--success);
}
.km-item[hidden] { display: none; }

/* ── 최근 복사 ── */
.km-recent {
  padding: 0.85rem 0.9rem 1rem;
  margin-bottom: 1.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.km-recent .km-sec-head { margin-bottom: 0.55rem; }
.km-recent .km-item { background: var(--surface); }

.km-clear {
  margin-left: auto;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--text-sub);
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.km-clear:hover { color: var(--text); border-color: var(--primary); }

.km-empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-sub);
}

@media (min-width: 768px) {
  .km-grid { gap: 0.65rem; }
  .km-item {
    min-width: 140px;
    min-height: 56px;
  }
}

@media (max-width: 480px) {
  .km-bar { padding: 0.6rem 0; }
  .km-chip { min-height: 44px; }
  .km-item {
    min-width: 104px;
    min-height: 48px;
    font-size: 0.9rem;
  }
  .km-recent { padding: 0.75rem 0.7rem 0.85rem; }
}

/* ── 터치 영역 보정 ──
   CLAUDE.md의 "최소 터치 영역 44px" 규칙을 지키되 보이는 크기는 그대로 둔다.
   버튼 위에 투명한 ::after를 깔아 히트 영역만 44px로 넓힌다. */
.km-reset { position: relative; }
.km-reset::after {
  content: '';
  position: absolute;
  inset: -7px;   /* 30px + 7×2 = 44px (검색어 지우기) */
}
