/* 게임 정보(도감) 화면 — 시안 v6.5 Info4(2026-10-07 전면 교체).
   띠 → 탭 여섯 → 검색·필터 → 목록 | 상세(데스크톱) · 전체 화면 상세(≤767px).
   ⚠ `body.cx4-page` 아래로만 건다 — 옛 style.css(이 화면 전용)의 같은 id 규칙을 이겨야 하고,
     다른 화면(빌더 장비 고르기)이 같이 쓰는 `.fchip`·`#tagbar` 규칙은 안 건드린다.
   ⚠ 색은 skin.css 토큰만 쓴다. 등급 테두리만 rarity 토큰(--rar-*)이다. */

.cx4-wrap {
  width: min(calc(100% - 2 * clamp(16px, 4.4%, 72px)), 1536px);
  margin: 0 auto; box-sizing: border-box;
}

/* ── 띠: 배경 그림을 얕게 깔고 「게임 정보」 + 탭 제목 ── */
.cx4-banner { position: relative; border-bottom: 1px solid var(--line); margin-top: -1px; }
.cx4-banner .cx4-wrap { position: relative; z-index: 1; padding: 40px 0 32px; }
.cx4-kicker { margin: 0 0 12px; color: var(--accent); font-size: var(--fs-sm); letter-spacing: .3em; }
body.bg3 .cx4-title {
  margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 34px; line-height: 1.2;
  color: var(--text); background: none; -webkit-text-fill-color: currentColor; text-shadow: none; letter-spacing: 0;
}

/* ── 탭 여섯 ── */
body.cx4-page .stabs.cx4-tabs {
  display: flex; flex-wrap: wrap; gap: 4px 28px; margin: 8px 0 0; padding: 0;
  border-bottom: 1px solid var(--line); background: none;
}
body.cx4-page .stabs .stab.cx4-tab {
  font: inherit; font-size: var(--fs-lg); min-height: 48px; padding: 0 2px; margin: 0 0 -1px;
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--text-2); cursor: pointer; white-space: nowrap; letter-spacing: .04em; box-shadow: none;
}
body.cx4-page .stabs .stab.cx4-tab:hover { color: var(--text); }
body.cx4-page .stabs .stab.cx4-tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); background: none; }
body.cx4-page .stabs .stab.cx4-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 검색 · 개수 · 필터 ── */
.cx4-filters { display: flex; flex-direction: column; gap: 16px; padding-top: 24px; }
body.cx4-page .cx4-filters nav { display: flex; flex-direction: column; gap: 16px; padding: 0; border: 0; background: none; }
body.cx4-page .cx4-searchrow { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin: 0; }
.cx4-search {
  flex: 0 1 480px; min-width: 0; display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 0 8px 0 16px; box-sizing: border-box;
  background: rgba(10, 8, 6, .5); border-top: 1px solid var(--text-3); border-bottom: 1px solid var(--text-3);
}
.cx4-search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.cx4-search svg { flex: none; width: 18px; height: 18px; color: var(--text-3); }
body.cx4-page .cx4-search input {
  flex: 1; min-width: 0; width: auto; align-self: stretch; padding: 0; margin: 0;
  background: transparent; border: 0; border-radius: 0; box-shadow: none; outline: none;
  color: var(--text); font: inherit; font-size: 16px;
}
body.cx4-page .cx4-search input::placeholder { color: var(--text-2); opacity: 1; }
body.cx4-page .cx4-count { margin: 0; color: var(--text); font-size: var(--fs-lg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx4-text {
  font: inherit; font-size: var(--fs-base); min-height: 40px; padding: 0 4px;
  background: none; border: 0; color: var(--accent); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.cx4-text:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
/* 슬롯·종류 칩(시안 `.x-sc`): 글자 + 개수, 고르면 금색 테두리 */
body.cx4-page .cx4-slotchips { display: flex; flex-wrap: wrap; gap: 8px; }
body.cx4-page .cx4-slotchips .fchip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px 0 8px;
  font: inherit; font-size: var(--fs-base); background: transparent; border: 1px solid var(--line); border-radius: 0;
  color: var(--text-2); cursor: pointer; white-space: nowrap;
}
body.cx4-page .cx4-slotchips .fchip:hover { border-color: var(--text-3); color: var(--text); }
body.cx4-page .cx4-slotchips .fchip.on,
body.cx4-page .cx4-slotchips .fchip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: rgba(200, 162, 76, .08); }
body.cx4-page .cx4-slotchips .fchip .fchip-ico { width: 20px; height: 20px; flex: none; }
body.cx4-page .cx4-slotchips .fchip .n { font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
body.cx4-page .cx4-slotchips .fchip.empty { opacity: 1; border-style: dashed; }
/* 등급 · 막(접힘) */
body.cx4-page .cx4-fold { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
body.cx4-page .cx4-fold > summary {
  min-height: 48px; display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none;
  color: var(--text); font-size: var(--fs-lg);
}
body.cx4-page .cx4-fold > summary::-webkit-details-marker { display: none; }
body.cx4-page .cx4-fold > summary::before {
  content: ''; width: 7px; height: 7px; flex: none; margin: 0 4px;
  border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg); transition: transform .15s;
}
body.cx4-page .cx4-fold[open] > summary::before { transform: rotate(45deg); }
body.cx4-page .cx4-fold .frow { display: flex; align-items: flex-start; gap: 10px; padding: 0 0 12px; }
/* 접힘 안의 칩(등급·막·레벨·학파·성질) — 시안 `.chip`: 32px · 12.5px, 고르면 금색 */
body.cx4-page .cx4-fold .fchip { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
body.cx4-page .cx4-fold .flabel { flex: none; width: 44px; padding-top: 8px; color: var(--text-3); font-size: var(--fs-sm); letter-spacing: .22em; white-space: nowrap; }

/* ── 목록 | 상세 ── */
body.cx4-page main.cx4-info {
  display: grid; grid-template-columns: clamp(280px, 32%, 440px) minmax(0, 1fr); gap: 32px; align-items: start;
  padding: 28px 0 64px;
}
body.cx4-page #list.cx4-list {
  list-style: none; margin: 0; padding: 0; max-height: none; overflow: visible;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px;
}
body.cx4-page #list li { padding: 0; background: none; box-shadow: none; }
body.cx4-page #list li.selected { background: none; box-shadow: none; }
body.cx4-page #list .x-item {
  display: flex; align-items: center; gap: 16px; width: 100%; min-height: 72px; box-sizing: border-box;
  padding: 8px 16px 8px 8px; background: rgba(18, 14, 10, .5); border: 1px solid var(--line-2);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
body.cx4-page #list .x-item:hover { border-color: var(--text-3); background: rgba(18, 14, 10, .5); }
body.cx4-page #list .x-item[aria-current="true"] { border-color: var(--accent); background: rgba(42, 35, 25, .7); }
body.cx4-page #list .x-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.cx4-page #list li.missing .x-item { box-shadow: inset 2px 0 0 var(--warn); }
/* 아이콘 틀(시안 `.x-ico`) — 정사각형 56px, 등급 색 테두리 */
body.cx4-page #list .x-ico {
  position: relative; width: 56px; height: 56px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rarity, var(--line)); background: radial-gradient(circle at 50% 40%, var(--surface-3) 0%, var(--bg) 75%);
}
body.cx4-page #list li:not([style]) .x-ico { border-color: var(--line); }
body.cx4-page #list .x-ico.r-spell { border-color: var(--text-3); border-radius: 0; }
body.cx4-page #list .x-ico .thumb { width: 100%; height: 100%; object-fit: contain; border: 0; background: none; }
body.cx4-page #list .x-ico.r-spell .thumb { border-radius: 0; }
body.cx4-page #list .x-item .tx { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
body.cx4-page #list .x-item .nm { font-size: var(--fs-lg); overflow-wrap: anywhere; color: var(--rarity, var(--text)); }
body.cx4-page #list .x-item .kd,
body.cx4-page #list .x-item .en { display: block; color: var(--text-2); font-size: var(--fs-sm); }
body.cx4-page #list .x-item .rr { margin-left: auto; font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
body.cx4-page #list li.none { padding: 18px 4px; color: var(--text-2); }

/* 목록 칸(목록 + 쪽 번호)·상태/클래스/종족/몬스터 줄·몬스터 본문 그릇·시트 본문 */
.cx4-listcol { min-width: 0; container-type: inline-size; }
body.cx4-page #list .codex-row .nm { color: var(--text); }
.cx4-monster { min-width: 0; }
.cx4-sheet-body { min-width: 0; }

/* 쪽 번호: 한 줄. 처음 · 끝 · 지금 앞뒤, 사이는 「…」 */
.cx4-pager { display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 2px; padding: 12px 0 4px; }
.cx4-pgnums { display: inline-flex; align-items: center; gap: 2px; }
.cx4-pg {
  font: inherit; font-size: var(--fs-lg); min-width: var(--m-touch); min-height: var(--m-touch); padding: 0 8px;
  background: none; border: 1px solid transparent; color: var(--text-2); cursor: pointer; font-variant-numeric: tabular-nums;
}
.cx4-pg:hover { color: var(--text); border-color: var(--line); }
.cx4-pg[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.cx4-pg:disabled { opacity: .4; cursor: not-allowed; border-color: transparent; }
.cx4-pg-txt { padding: 0 12px; }
.cx4-pg.gapb { margin-left: 18px; position: relative; }
.cx4-pg.gapb::before { content: '…'; position: absolute; left: -14px; color: var(--text-3); }
.cx4-pgnow { display: none; min-width: 5em; text-align: center; font-variant-numeric: tabular-nums; color: var(--text-2); }
/* 목록 폭이 좁아지면 쪽 단추를 잘라내지 않고 현재 쪽과 앞뒤 이동으로 접는다. */
@container (max-width: 380px) {
  .cx4-pgnums { display: none; }
  .cx4-pgnow { display: inline-block; }
}

/* 상세: 오른쪽 칸에 붙어 있다(시안 `.x-detail`). 카드 생김새는 tooltip.css 그대로다. */
body.cx4-page #detail.cx4-detail { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; padding: 0; }
.cx4-dhead-link { justify-content: flex-end; margin-bottom: 4px; }
.cx4-dhead { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 12px; }
body.bg3 .cx4-dhead .tt-name { margin: 0; color: var(--text); font-size: 26px; font-weight: 400; }
/* 도감 본문 그릇 — 낱쪽의 읽기 폭(832px)·바깥 여백을 걷고 칸을 채운다. */
body.cx4-page .cx4-codexbody.cx-main { max-width: none; margin: 0; padding: 0; }
body.cx4-page .cx4-codexbody #monster-app { max-width: none; padding: 0; }
body.cx4-page .cx4-codexbody #monster-app .monster-detail { max-width: none; }
/* 상세의 텍스트 칩에만 붙는 작은 표식. 게임 그림이 있는 칩은 기존 그림을 살린다. */
body.cx4-page .cx4-chip-glyph {
  display: inline-block; width: 12px; height: 12px; flex: none; margin-right: 5px;
  vertical-align: -1px; border: 1px solid currentColor; transform: rotate(45deg); opacity: .75;
}
body.cx4-page .cx4-chip-icon { display: inline-block; width: 16px; height: 16px; flex: none; margin-right: 5px; vertical-align: middle; object-fit: contain; }
body.cx4-page .tt-tag .cx4-chip-glyph, body.cx4-page .st-stat .cx4-chip-glyph,
body.cx4-page .st-cost .cx4-chip-glyph { width: 9px; height: 9px; }
body.cx4-page .monster-stats dt .cx4-chip-glyph { width: 8px; height: 8px; }
body.cx4-page .monster-resistances li .cx4-chip-glyph { margin-right: 9px; }

/* ── 좁은 폭 전체 화면 상세(≤767px) ── */
.cx4-sheet {
  position: fixed; inset: 0; z-index: 60; overflow-y: auto; box-sizing: border-box;
  background: var(--bg); padding: 0 16px calc(24px + env(safe-area-inset-bottom, 0px));
}
.cx4-sheet-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center;
  margin: 0 -16px 12px; padding: max(4px, env(safe-area-inset-top, 0px)) 8px 4px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.cx4-back {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--m-touch); padding: 0 12px 0 4px;
  background: none; border: 0; color: var(--text); font: inherit; font-size: var(--fs-lg); cursor: pointer;
}
.cx4-back svg { width: 22px; height: 22px; }
.cx4-back:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
body.cx4-sheet-open { overflow: hidden; }
body.cx4-sheet-open .tabbar { display: none; }

@media (max-width: 1100px) {
  body.cx4-page main.cx4-info { gap: 24px; }
}
@media (max-width: 767px) {
  .cx4-banner .cx4-wrap { padding: 24px 0 20px; }
  body.bg3 .cx4-title { font-size: 28px; }
  body.cx4-page .stabs.cx4-tabs { gap: 0 20px; }
  body.cx4-page main.cx4-info { grid-template-columns: minmax(0, 1fr); padding-top: 20px; }
  body.cx4-page #detail.cx4-detail { display: none; }
  .cx4-search { flex: 1 1 100%; }
  .cx4-text { min-height: var(--m-touch); }
  body.cx4-page .cx4-slotchips .fchip { min-height: var(--m-touch); }
  .cx4-pgnums { display: none; }
  .cx4-pgnow { display: inline-block; }
}

/* 원본 Info4의 탐색 줄과 단일 상세 카드. 공유 툴팁의 내용·판정은 그대로 쓴다. */
body.cx4-page .cx4-search { border: 1px solid var(--text-3); }
.cx4-suggestions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; color: var(--text-2); font-size: 13px; }
.cx4-suggestions button { border: 0; background: none; color: var(--gold); font: inherit; cursor: pointer; min-height: 36px; padding: 4px 0; }
.cx4-detail-nav { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0 0 14px; margin-bottom: 20px; border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 12px; }
.cx4-detail-nav > span { overflow-wrap: anywhere; min-width: 0; }
.cx4-detail-nav > div { display: flex; gap: 12px; }
.cx4-detail-nav button { min-height: 36px; border: 0; background: none; color: var(--gold); font: inherit; cursor: pointer; padding: 0 2px; }
.cx4-detail-nav button:disabled { color: var(--text-3); cursor: default; }
body.cx4-page :is(#detail, #detailsheet-body) :is(.tt, .st) { max-width: none; border: 0; background: none; box-shadow: none; padding: 0; }
body.cx4-page :is(#detail, #detailsheet-body) :is(.tt-head, .st-head) { justify-content: flex-start; gap: 20px; padding: 0 0 20px; align-items: center; }
body.cx4-page :is(#detail, #detailsheet-body) :is(.tt-icon, .st-icon) { order: -1; width: 88px; height: 88px; flex: 0 0 88px; border-radius: 0; background: var(--surface-2); border: 1px solid var(--rarity, var(--line)); box-sizing: border-box; object-fit: contain; }
body.cx4-page :is(#detail, #detailsheet-body) :is(.tt-title, .st-title) { min-width: 0; flex: 1; }
body.cx4-page :is(#detail, #detailsheet-body) :is(.tt-name, .st-name) { font: 400 28px/1.25 var(--font-title); overflow-wrap: anywhere; }
/* 아이템 머리의 그림과 제목을 왼쪽에 두고 사방 여백을 고르게 둔다. */
body.cx4-page :is(#detail, #detailsheet-body) .tt-head { justify-content: flex-start; padding: 20px; }
body.cx4-page :is(#detail, #detailsheet-body) .tt-title { flex: 0 1 auto; }
.cx4-codexbody :is(.cx-class-tree, .cx-class-intro, .cx-subclass, .cx-subrace) { padding: 16px 0; border: 0; border-top: 1px solid var(--line); background: none; }
.cx4-codexbody :is(.cx-levels, .cx-branch) { grid-template-columns: minmax(0, 1fr); }
.cx4-codexbody .cx-level { padding: 12px; background: none; }
.cx4-codexbody .cx-level::before { display: none; }
.cx4-codexbody .cx-tree-head { flex-direction: column; align-items: flex-start; }
.cx4-codexbody .cx-subclass-nav { justify-content: flex-start; }
.cx4-chip-icon, .cx4-codexbody .fchip-ico { width: 20px; height: 20px; flex: none; }
.cx4-monster .monster-detail-grid { display: flex; flex-direction: column; gap: 0; }
.cx4-monster .monster-detail-grid > * { width: 100%; min-width: 0; }
.cx4-monster :is(.monster-section, .monster-stat-block, .monster-card) { border: 0; border-top: 1px solid var(--line); background: none; box-shadow: none; padding-inline: 0; }
body.cx4-page #monster-app { padding: 0; }
@media(max-width: 767px) {
  .cx4-detail-nav button, .cx4-suggestions button, #monsteractchips button, #codexfilters-reset { min-height: var(--m-touch); }
  body.cx4-page :is(#detail, #detailsheet-body) :is(.tt-icon, .st-icon) { width: 64px; height: 64px; flex-basis: 64px; }
  body.cx4-page :is(#detail, #detailsheet-body) :is(.tt-name, .st-name) { font-size: 24px; }
  body.cx4-page :is(#detail, #detailsheet-body) .tt-head { padding: 16px; gap: 16px; }
}

.cx4-entry-icon { width: 64px; height: 64px; object-fit: contain; flex: none; }
.cx4-resource { display: inline-block; width: 14px; height: 14px; background: var(--gold); transform: rotate(45deg); }
.cx4-resource.bonus { border-radius: 50%; background: var(--text-2); transform: none; }
/* 아이템 기술의 작은 비용 글자에 맞춘다. 마름모는 회전하면 외곽이 더 커진다. */
.tt-grant-cost .cx4-resource { width: .7em; height: .7em; margin-inline: 2px 4px; vertical-align: middle; }
.cx4-resource.move { clip-path: polygon(40% 0, 75% 0, 60% 40%, 95% 40%, 25% 100%, 40% 55%, 5% 55%); transform: none; }
