/* ==========================================================================
   COGO Study Map v2 — 배울 단원 찾기 모달
   - 모든 스타일은 .cg-sm 안에서만 동작 (기존 사이트 스타일과 충돌 없음)
   - 필요: shared/cogo-tokens.css
   - 핵심 장치: 왼쪽 대단원 목록 = 지하철 노선도 (과목 = 노선, 대단원 = 역)
   ========================================================================== */

.cg-sm {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 24px;
  font-family: var(--cg-font);
  color: var(--cg-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.45;
}
/* 초기화는 :where()로 우선순위 0 — 아래 컴포넌트 규칙(.cg-sm .cg-sm-*)이 항상 이김 */
:where(.cg-sm) *, :where(.cg-sm) *::before, :where(.cg-sm) *::after { box-sizing: border-box; }
:where(.cg-sm) :where(button, input, select) { font: inherit; color: inherit; margin: 0; letter-spacing: inherit; }
:where(.cg-sm) button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
:where(.cg-sm) :where(p, h2, h3, h4) { margin: 0; }
:where(.cg-sm) :focus { outline: none; }
.cg-sm :focus-visible { outline: 2.5px solid rgba(46, 91, 255, .6); outline-offset: 2px; }
.cg-sm .cg-ic { flex: none; display: block; }
.cg-sm [hidden] { display: none !important; }

.cg-sm .cg-sm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 26, 43, .46);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.cg-sm .cg-sm-sheet {
  position: relative;
  width: min(1240px, 100%);
  height: min(880px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--cg-surface);
  border-radius: 28px;
  box-shadow: var(--cg-shadow-sheet);
}

/* ---------- 머리 (제목·검색·과목) ---------- */
.cg-sm .cg-sm-head {
  position: relative;
  padding: 26px 32px 0;
  background: var(--cg-paper);
}
.cg-sm .cg-sm-head-row { display: flex; align-items: flex-start; gap: 16px; }
.cg-sm .cg-sm-head-text { flex: 1; min-width: 0; }
.cg-sm .cg-sm-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--cg-blue);
}
.cg-sm .cg-sm-title {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -.025em;
}
.cg-sm .cg-sm-lede { margin-top: 6px; font-size: 14.5px; font-weight: 500; color: var(--cg-ink-3); }

.cg-sm .cg-sm-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(440px, 38vw);
  height: 50px;
  margin-top: 22px;
  padding: 0 10px 0 16px;
  background: var(--cg-surface);
  border: 1.5px solid var(--cg-line);
  border-radius: 14px;
  color: var(--cg-ink-3);
  cursor: text;
  transition: border-color .2s, box-shadow .2s;
}
.cg-sm .cg-sm-search:hover { border-color: var(--cg-ink-4); }
.cg-sm .cg-sm-search:focus-within { border-color: var(--cg-blue); box-shadow: 0 0 0 4px rgba(46, 91, 255, .12); color: var(--cg-blue); }
.cg-sm .cg-sm-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--cg-ink);
}
.cg-sm .cg-sm-search input:focus-visible { outline: none; }
.cg-sm .cg-sm-search input::placeholder { color: var(--cg-ink-4); font-weight: 500; }
.cg-sm .cg-sm-search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.cg-sm .cg-sm-kbd {
  padding: 1px 8px;
  border: 1px solid var(--cg-line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--cg-surface-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--cg-ink-3);
  font-family: inherit;
}
.cg-sm .cg-sm-clear {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  place-items: center;
  color: var(--cg-ink-3);
}
.cg-sm .cg-sm-clear:hover { background: var(--cg-paper); color: var(--cg-ink); }
.cg-sm .cg-sm-search.has-value .cg-sm-clear { display: grid; }
.cg-sm .cg-sm-search.has-value .cg-sm-kbd { display: none; }

.cg-sm .cg-sm-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-top: 22px;
  border-radius: 14px;
  background: var(--cg-surface);
  border: 1.5px solid var(--cg-line);
  transition: background .2s, color .2s, border-color .2s;
}
.cg-sm .cg-sm-close:hover { background: var(--cg-ink); border-color: var(--cg-ink); color: #fff; }

/* 과목 탭 — 노선 배지 */
.cg-sm .cg-sm-tabs {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
  padding-bottom: 18px;
}
.cg-sm .cg-sm-tab {
  --c: var(--cg-ink);
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  height: 46px;
  padding: 0 12px 0 9px;
  background: var(--cg-surface);
  border: 1px solid var(--cg-line);
  border-radius: 14px;
  white-space: nowrap;
  transition: background .25s var(--cg-ease), border-color .25s, color .25s, transform .12s;
}
.cg-sm .cg-sm-tab:hover { border-color: var(--cg-ink-4); }
.cg-sm .cg-sm-tab:active { transform: scale(.97); }
.cg-sm .cg-sm-tab[aria-selected="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.cg-sm .cg-sm-tab.is-empty:not([aria-selected="true"]) { color: var(--cg-ink-4); }
.cg-sm .cg-sm-tab.is-empty:not([aria-selected="true"]) .cg-sm-badge { opacity: .4; }
.cg-sm .cg-sm-tab-name { font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.cg-sm .cg-sm-tab-count {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--cg-ink-3);
  font-variant-numeric: tabular-nums;
}
.cg-sm .cg-sm-tab[aria-selected="true"] .cg-sm-tab-count { color: rgba(255, 255, 255, .85); }

.cg-sm .cg-sm-badge {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.cg-sm .cg-sm-tab[aria-selected="true"] .cg-sm-badge { background: #fff; color: var(--c); }

/* 머리 맨 아래 = 과목별 문제 비율 띠 (지도 범례) */
.cg-sm .cg-sm-share {
  display: flex;
  gap: 2px;
  height: 5px;
  margin: 0 -32px;
  background: var(--cg-line);
}
.cg-sm .cg-sm-share i {
  display: block;
  min-width: 4px;
  height: 100%;
  background: var(--c);
  transform-origin: left center;
  transition: opacity .3s, flex-grow .5s var(--cg-ease);
  cursor: pointer;
}
.cg-sm .cg-sm-share.has-focus i { opacity: .22; }
.cg-sm .cg-sm-share.has-focus i.is-on { opacity: 1; }

/* ---------- 필터 줄 ---------- */
.cg-sm .cg-sm-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--cg-line-2);
  background: var(--cg-surface);
}
.cg-sm .cg-sm-field {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 168px;
  height: 50px;
  padding: 0 36px 0 14px;
  background: var(--cg-surface);
  border: 1px solid var(--cg-line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.cg-sm .cg-sm-field--wide { min-width: 196px; }
.cg-sm .cg-sm-field:hover { border-color: var(--cg-ink-4); }
.cg-sm .cg-sm-field:focus-within { border-color: var(--cg-blue); box-shadow: 0 0 0 4px rgba(46, 91, 255, .12); }
.cg-sm .cg-sm-field.is-set { border-color: var(--cg-ink); box-shadow: inset 0 0 0 .5px var(--cg-ink); }
.cg-sm .cg-sm-field-label { font-size: 11.5px; font-weight: 600; line-height: 1.2; color: var(--cg-ink-3); }
.cg-sm .cg-sm-field select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  padding: 0;
  margin-top: 2px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
.cg-sm .cg-sm-field select:focus-visible { outline: none; }
.cg-sm .cg-sm-field > .cg-ic {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cg-ink-3);
  pointer-events: none;
}

.cg-sm .cg-sm-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 16px;
  margin-left: auto;
  font-size: 13px;
  color: var(--cg-ink-3);
}
.cg-sm .cg-sm-meta b {
  margin-right: 1px;
  font-size: 15px;
  font-weight: 800;
  color: var(--cg-ink);
  font-variant-numeric: tabular-nums;
}
.cg-sm .cg-sm-meta-q {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--cg-yellow-50);
  color: var(--cg-ink-2);
  font-weight: 700;
}
.cg-sm .cg-sm-live { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.cg-sm .cg-sm-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cg-green);
  box-shadow: 0 0 0 3px rgba(22, 163, 106, .18);
}

/* ---------- 본문: 노선도 + 상세 ---------- */
.cg-sm .cg-sm-body {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 0;
}

.cg-sm .cg-sm-rail {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 28px 22px;
  background: var(--cg-surface-2);
  border-right: 1px solid var(--cg-line-2);
}
.cg-sm .cg-sm-rail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 4px 12px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--cg-ink-2);
}
.cg-sm .cg-sm-rail-head span { font-weight: 600; color: var(--cg-ink-3); }
.cg-sm .cg-sm-rail-empty { padding: 24px 6px; font-size: 13.5px; color: var(--cg-ink-3); }

.cg-sm .cg-sm-line { --c: var(--cg-ink); position: relative; margin-bottom: 16px; }
.cg-sm .cg-sm-line:last-child { margin-bottom: 0; }
.cg-sm .cg-sm-line-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  font-size: 13px;
  font-weight: 800;
}
.cg-sm .cg-sm-line-head small {
  font-size: 12px;
  font-weight: 600;
  color: var(--cg-ink-3);
  font-variant-numeric: tabular-nums;
}
.cg-sm .cg-sm-track {
  position: absolute;
  left: 10px;
  top: 14px;
  bottom: 21px;
  width: 4px;
  border-radius: 2px;
  background: var(--c);
  transform-origin: top center;
}

.cg-sm .cg-sm-station {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  padding: 0 12px 0 36px;
  border-radius: 12px;
}
.cg-sm .cg-sm-station::before {
  content: "";
  position: absolute;
  inset: 2px 0 2px 26px;
  z-index: -1;
  border-radius: 11px;
  transition: background .2s, box-shadow .2s;
}
.cg-sm .cg-sm-station:hover::before { background: rgba(22, 26, 43, .045); }
.cg-sm .cg-sm-station:focus-visible { outline: none; }
.cg-sm .cg-sm-station:focus-visible::before { box-shadow: var(--cg-focus); }
.cg-sm .cg-sm-node {
  position: absolute;
  left: 5px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--c);
  color: #fff;
  transition: transform .3s var(--cg-ease-spring), background .2s, border-color .2s, box-shadow .3s;
}
.cg-sm .cg-sm-node .cg-ic { display: none; }
.cg-sm .cg-sm-station-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--cg-ink-2);
}
.cg-sm .cg-sm-station-sel {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--cg-blue-50);
  color: var(--cg-blue);
  font-size: 11.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.cg-sm .cg-sm-station-count {
  flex: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cg-ink-3);
  font-variant-numeric: tabular-nums;
}

/* 지금 보고 있는 역 */
.cg-sm .cg-sm-station[aria-current="true"]::before { background: var(--cg-surface); box-shadow: 0 0 0 1px var(--cg-line), var(--cg-shadow-lift); }
.cg-sm .cg-sm-station[aria-current="true"] .cg-sm-station-name { color: var(--cg-ink); font-weight: 800; }
.cg-sm .cg-sm-station[aria-current="true"] .cg-sm-station-count { color: var(--cg-ink-2); }
.cg-sm .cg-sm-station[aria-current="true"] .cg-sm-node {
  transform: scale(1.3);
  background: var(--cg-ink);
  border-color: var(--cg-ink);
  box-shadow: 0 0 0 3.5px var(--cg-yellow);
}
/* 고른 역 */
.cg-sm .cg-sm-station.is-part .cg-sm-node { background: var(--cg-blue-100); border-color: var(--cg-blue); }
.cg-sm .cg-sm-station.is-full .cg-sm-node { background: var(--cg-blue); border-color: var(--cg-blue); }
.cg-sm .cg-sm-station.is-full .cg-sm-node .cg-ic { display: block; }
.cg-sm .cg-sm-station.is-full[aria-current="true"] .cg-sm-node { background: var(--cg-blue); border-color: var(--cg-blue); }

/* 열 때 한 번: 노선이 그어지고 역이 찍힘 */
.cg-sm .cg-sm-rail.is-drawing .cg-sm-track { animation: cg-grow-y .75s var(--cg-ease) both; animation-delay: calc(var(--g, 0) * 90ms + 120ms); }
.cg-sm .cg-sm-rail.is-drawing .cg-sm-node { animation: cg-pop .45s var(--cg-ease-spring) both; animation-delay: calc(var(--g, 0) * 90ms + var(--s, 0) * 55ms + 260ms); }
.cg-sm .cg-sm-rail.is-drawing .cg-sm-line-head,
.cg-sm .cg-sm-rail.is-drawing .cg-sm-station-name,
.cg-sm .cg-sm-rail.is-drawing .cg-sm-station-count { animation: cg-fade-in .4s ease both; animation-delay: calc(var(--g, 0) * 90ms + var(--s, 0) * 55ms + 220ms); }

/* ---------- 상세 ---------- */
.cg-sm .cg-sm-detail {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 26px 32px 36px;
}
.cg-sm .cg-sm-dwrap { --c: var(--cg-ink); }
.cg-sm .cg-sm-dwrap.is-entering .cg-sm-dhead,
.cg-sm .cg-sm-dwrap.is-entering .cg-sm-mid,
.cg-sm .cg-sm-dwrap.is-entering .cg-sm-more { animation: cg-rise .32s var(--cg-ease) both; animation-delay: calc(var(--m, 0) * 45ms); }

.cg-sm .cg-sm-crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--cg-ink-3);
}
.cg-sm .cg-sm-crumb .cg-sm-badge { width: 20px; height: 20px; font-size: 11px; }
.cg-sm .cg-sm-crumb .cg-ic { color: var(--cg-ink-4); }

.cg-sm .cg-sm-dhead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--cg-line-2);
}
.cg-sm .cg-sm-dtitle { font-size: 28px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
.cg-sm .cg-sm-facts { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; font-size: 13px; color: var(--cg-ink-3); }
.cg-sm .cg-sm-facts b {
  margin-right: 1px;
  font-size: 15px;
  font-weight: 800;
  color: var(--cg-ink);
  font-variant-numeric: tabular-nums;
}

.cg-sm .cg-sm-selall {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px 0 13px;
  border: 1.5px solid var(--cg-ink);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  transition: background .2s, color .2s, border-color .2s;
}
.cg-sm .cg-sm-selall .cg-ic { color: var(--cg-ink-3); }
.cg-sm .cg-sm-selall:hover { background: var(--cg-ink); color: #fff; }
.cg-sm .cg-sm-selall:hover .cg-ic { color: #fff; }
.cg-sm .cg-sm-selall[aria-pressed="true"] { background: var(--cg-blue); border-color: var(--cg-blue); color: #fff; }
.cg-sm .cg-sm-selall[aria-pressed="true"] .cg-ic { color: #fff; }
.cg-sm .cg-sm-selall[aria-pressed="true"]:hover { background: var(--cg-blue-600); border-color: var(--cg-blue-600); }

.cg-sm .cg-sm-mid { margin-top: 24px; }
.cg-sm .cg-sm-mid-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cg-sm .cg-sm-mid-name { font-size: 16.5px; font-weight: 800; letter-spacing: -.01em; }
.cg-sm .cg-sm-mid-count { font-size: 13px; font-weight: 600; color: var(--cg-ink-3); font-variant-numeric: tabular-nums; }
.cg-sm .cg-sm-mid-all {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--cg-blue);
}
.cg-sm .cg-sm-mid-all:hover { background: var(--cg-blue-50); }
.cg-sm .cg-sm-mid-all[aria-pressed="true"] { color: var(--cg-ink-3); }

.cg-sm .cg-sm-smalls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 10px;
}
.cg-sm .cg-sm-small {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 14px 14px 14px 16px;
  background: var(--cg-surface);
  border: 1px solid var(--cg-line);
  border-radius: 14px;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.cg-sm .cg-sm-small:hover { border-color: var(--cg-ink-4); }
.cg-sm .cg-sm-small[aria-pressed="true"] {
  background: var(--cg-blue-50);
  border-color: var(--cg-blue);
  box-shadow: inset 0 0 0 1px var(--cg-blue);
}
.cg-sm .cg-sm-small-body { flex: 1; min-width: 0; }
.cg-sm .cg-sm-small-name { display: block; font-size: 15px; font-weight: 700; line-height: 1.35; }
.cg-sm .cg-sm-small-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--cg-ink-3);
}
.cg-sm .cg-sm-small-meta b { font-weight: 800; color: var(--cg-ink-2); font-variant-numeric: tabular-nums; }
.cg-sm .cg-sm-tag {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--cg-paper);
  font-weight: 600;
  color: var(--cg-ink-3);
}
.cg-sm .cg-sm-small[aria-pressed="true"] .cg-sm-tag { background: #fff; }
.cg-sm .cg-sm-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--cg-line);
  color: var(--cg-ink-3);
  transition: background .18s, border-color .18s, color .18s;
}
.cg-sm .cg-sm-toggle .i-check { display: none; }
.cg-sm .cg-sm-small:hover .cg-sm-toggle { border-color: var(--cg-blue); color: var(--cg-blue); }
.cg-sm .cg-sm-small[aria-pressed="true"] .cg-sm-toggle { background: var(--cg-blue); border-color: var(--cg-blue); color: #fff; }
.cg-sm .cg-sm-small[aria-pressed="true"] .cg-sm-toggle .i-plus { display: none; }
.cg-sm .cg-sm-small[aria-pressed="true"] .cg-sm-toggle .i-check { display: block; }
.cg-sm .cg-sm-small.just-toggled .cg-sm-toggle { animation: cg-pop .4s var(--cg-ease-spring); }

/* 검색 일치 = 형광펜 */
.cg-sm .cg-sm-mark {
  padding: 0 1px;
  border-radius: 2px;
  background: linear-gradient(transparent 52%, var(--cg-yellow) 52%);
  color: inherit;
}

/* 다른 대단원 둘러보기 */
.cg-sm .cg-sm-more { margin-top: 36px; padding-top: 20px; border-top: 1px dashed var(--cg-line); }
.cg-sm .cg-sm-more-title { margin-bottom: 12px; font-size: 13.5px; font-weight: 700; color: var(--cg-ink-3); }
.cg-sm .cg-sm-more-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.cg-sm .cg-sm-more-item {
  --c: var(--cg-ink);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--cg-surface-2);
  border: 1px solid transparent;
  border-radius: 12px;
  transition: border-color .18s, background .18s;
}
.cg-sm .cg-sm-more-item:hover { background: var(--cg-surface); border-color: var(--cg-line); }
.cg-sm .cg-sm-more-item .cg-sm-badge { width: 22px; height: 22px; font-size: 11px; }
.cg-sm .cg-sm-more-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 700; }
.cg-sm .cg-sm-more-name small { margin-right: 6px; font-size: 12px; font-weight: 600; color: var(--cg-ink-3); }
.cg-sm .cg-sm-more-count { font-size: 12.5px; font-weight: 600; color: var(--cg-ink-3); font-variant-numeric: tabular-nums; }
.cg-sm .cg-sm-more-item .cg-ic { color: var(--cg-ink-4); transition: transform .2s var(--cg-ease), color .2s; }
.cg-sm .cg-sm-more-item:hover .cg-ic { color: var(--cg-ink); transform: translateX(2px); }

/* 결과 없음 */
.cg-sm .cg-sm-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 64px 20px;
  text-align: center;
}
.cg-sm .cg-sm-empty svg { margin-bottom: 10px; }
.cg-sm .cg-sm-empty strong { font-size: 17px; font-weight: 800; }
.cg-sm .cg-sm-empty p { max-width: 340px; font-size: 13.5px; line-height: 1.6; color: var(--cg-ink-3); }
.cg-sm .cg-sm-empty button {
  margin-top: 12px;
  height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1.5px solid var(--cg-ink);
  font-size: 13.5px;
  font-weight: 700;
}
.cg-sm .cg-sm-empty button:hover { background: var(--cg-ink); color: #fff; }

/* ---------- 바닥 (선택한 범위) ---------- */
.cg-sm .cg-sm-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px 14px 32px;
  background: var(--cg-surface);
  border-top: 1px solid var(--cg-line);
}
.cg-sm .cg-sm-scope { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.cg-sm .cg-sm-scope-label { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--cg-ink-3); }
.cg-sm .cg-sm-scope-n {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--cg-blue);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.cg-sm .cg-sm-chips {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.cg-sm .cg-sm-chips::-webkit-scrollbar { display: none; }
.cg-sm .cg-sm-chip {
  --c: var(--cg-ink);
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 4px 0 7px;
  border-radius: 999px;
  background: var(--cg-surface);
  border: 1px solid var(--cg-line);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.cg-sm .cg-sm-chip .cg-sm-badge { width: 20px; height: 20px; font-size: 10.5px; }
.cg-sm .cg-sm-chip-path { max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--cg-ink-3); }
.cg-sm .cg-sm-chip-x {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--cg-ink-3);
}
.cg-sm .cg-sm-chip-x:hover { background: var(--cg-paper); color: var(--cg-ink); }
.cg-sm .cg-sm-chip.is-new { animation: cg-pop .38s var(--cg-ease-spring) both; }
.cg-sm .cg-sm-token {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px dashed var(--cg-line);
  font-size: 13px;
  font-weight: 700;
  color: var(--cg-ink-2);
  white-space: nowrap;
}
.cg-sm .cg-sm-note { flex: none; font-size: 12px; font-weight: 600; color: var(--cg-amber); white-space: nowrap; }

.cg-sm .cg-sm-total { flex: none; display: flex; align-items: baseline; gap: 3px; }
.cg-sm .cg-sm-total b { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cg-sm .cg-sm-total span { font-size: 14px; font-weight: 700; color: var(--cg-ink-2); }

.cg-sm .cg-sm-reset {
  flex: none;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--cg-ink-3);
}
.cg-sm .cg-sm-reset:hover { background: var(--cg-paper); color: var(--cg-ink); }
.cg-sm .cg-sm-apply {
  flex: none;
  height: 52px;
  padding: 0 28px;
  border-radius: 14px;
  background: var(--cg-blue);
  color: #fff;
  font-size: 15.5px;
  font-weight: 800;
  box-shadow: 0 12px 24px -12px rgba(46, 91, 255, .75);
  transition: background .2s, transform .12s, box-shadow .2s;
}
.cg-sm .cg-sm-apply:hover { background: var(--cg-blue-600); }
.cg-sm .cg-sm-apply:active { transform: translateY(1px); }
.cg-sm .cg-sm-apply:disabled { background: var(--cg-ink-4); box-shadow: none; cursor: not-allowed; }

/* ---------- 열기·닫기 ---------- */
.cg-sm.is-opening .cg-sm-backdrop { animation: cg-fade-in .3s ease both; }
.cg-sm.is-opening .cg-sm-sheet { animation: cg-sm-sheet-in .55s var(--cg-ease) both; }
.cg-sm.is-opening .cg-sm-share i { animation: cg-grow-x .7s var(--cg-ease) both; animation-delay: calc(var(--i, 0) * 45ms + 260ms); }
.cg-sm.is-closing .cg-sm-backdrop { animation: cg-sm-fade-out .22s ease both; }
.cg-sm.is-closing .cg-sm-sheet { animation: cg-sm-sheet-out .22s ease both; }
@keyframes cg-sm-sheet-in { from { opacity: 0; transform: translateY(22px) scale(.985) } to { opacity: 1; transform: none } }
@keyframes cg-sm-sheet-out { to { opacity: 0; transform: translateY(12px) scale(.99) } }
@keyframes cg-sm-fade-out { to { opacity: 0 } }

/* ---------- 반응형 ---------- */
@media (max-width: 1140px) {
  .cg-sm .cg-sm-tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
  .cg-sm .cg-sm-tabs::-webkit-scrollbar { display: none; }
  .cg-sm .cg-sm-tab { flex: none; }
  .cg-sm .cg-sm-body { grid-template-columns: 264px minmax(0, 1fr); }
  .cg-sm .cg-sm-meta .cg-sm-live { display: none; }
}

@media (max-width: 860px) {
  .cg-sm { padding: 0; }
  .cg-sm .cg-sm-sheet { width: 100%; height: 100%; border-radius: 0; }
  .cg-sm .cg-sm-head { padding: 18px 16px 0; }
  .cg-sm .cg-sm-head-row { flex-wrap: wrap; gap: 12px; }
  .cg-sm .cg-sm-head-text { flex-basis: calc(100% - 62px); }
  .cg-sm .cg-sm-title { font-size: 24px; }
  .cg-sm .cg-sm-lede { font-size: 13.5px; }
  .cg-sm .cg-sm-close { order: 2; margin-top: 0; width: 46px; height: 46px; }
  .cg-sm .cg-sm-search { order: 3; width: 100%; margin-top: 0; }
  .cg-sm .cg-sm-tabs { margin-top: 14px; padding-bottom: 14px; }
  .cg-sm .cg-sm-tab { height: 42px; }
  .cg-sm .cg-sm-share { margin: 0 -16px; }
  .cg-sm .cg-sm-filters { padding: 10px 16px; overflow-x: auto; scrollbar-width: none; }
  .cg-sm .cg-sm-filters::-webkit-scrollbar { display: none; }
  .cg-sm .cg-sm-field { flex: none; min-width: 150px; height: 46px; }
  .cg-sm .cg-sm-meta { display: none; }

  .cg-sm .cg-sm-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .cg-sm .cg-sm-rail {
    display: flex;
    align-items: center;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--cg-line-2);
    scrollbar-width: none;
  }
  .cg-sm .cg-sm-rail::-webkit-scrollbar { display: none; }
  .cg-sm .cg-sm-rail-head, .cg-sm .cg-sm-track, .cg-sm .cg-sm-line-head small, .cg-sm .cg-sm-line-name { display: none; }
  .cg-sm .cg-sm-line { flex: none; display: flex; align-items: center; gap: 6px; margin: 0; }
  .cg-sm .cg-sm-line-head { height: auto; }
  .cg-sm .cg-sm-station {
    width: auto;
    height: 38px;
    padding: 0 12px 0 28px;
    background: var(--cg-surface);
    border: 1px solid var(--cg-line);
    border-radius: 999px;
  }
  .cg-sm .cg-sm-station::before { display: none; }
  .cg-sm .cg-sm-node { left: 9px; width: 12px; height: 12px; margin-top: -6px; border-width: 2.5px; }
  .cg-sm .cg-sm-station[aria-current="true"] { background: var(--cg-ink); border-color: var(--cg-ink); }
  .cg-sm .cg-sm-station[aria-current="true"] .cg-sm-station-name,
  .cg-sm .cg-sm-station[aria-current="true"] .cg-sm-station-count { color: #fff; }
  .cg-sm .cg-sm-station[aria-current="true"] .cg-sm-node { transform: none; background: var(--cg-yellow); border-color: var(--cg-yellow); box-shadow: none; }
  .cg-sm .cg-sm-station:focus-visible { outline: 2.5px solid rgba(46, 91, 255, .6); outline-offset: 2px; }

  .cg-sm .cg-sm-detail { padding: 18px 16px 28px; }
  .cg-sm .cg-sm-dhead { flex-direction: column; align-items: stretch; }
  .cg-sm .cg-sm-dtitle { font-size: 24px; }
  .cg-sm .cg-sm-selall { justify-content: center; }
  .cg-sm .cg-sm-smalls { grid-template-columns: 1fr; }

  .cg-sm .cg-sm-foot { flex-wrap: wrap; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .cg-sm .cg-sm-scope { flex-basis: 100%; }
  .cg-sm .cg-sm-total { margin-right: auto; }
  .cg-sm .cg-sm-apply { padding: 0 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .cg-sm *, .cg-sm *::before, .cg-sm *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
}
