/* ═══════════════════════════════════════════════════════════
   Global Apparel Term Guide — 3D Tornado Term Stream
   Dark / Bright themes · category grid view
   ═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Dark (default) ── */
  --bg:      #090a0d;
  --bg-2:    #0d0e12;
  --surface: #121319;
  --surface-2: #171922;
  --ivory:   #f5f6f8;
  --line:    #242630;
  --line-2:  #2f323e;
  --line-strong: #363a47;
  --text-1:  #f5f6f8;
  --text-2:  #a8acb7;
  --text-3:  #686d79;
  --muted-2: #5c616d;
  --warm-gray: #8c8880;   /* 카드 캡션 보조 정보 */
  /* 브랜드 블루(#0077ff, H212°)에서 채도만 낮춘 슬레이트.
     로고와 같은 색상각을 공유해 계열감은 남기되 화면에서는 조용하게. */
  --accent:      #8598ad;
  --accent-soft: rgba(133,152,173,0.14);
  --accent-line: #8598ad;

  --cat-accent:  #aeb9ff;
  --photo-bg:    #17181c;
  --hover:       rgba(255,255,255,0.06);
  --input-bg:    rgba(255,255,255,0.05);
  --input-bg-focus: rgba(255,255,255,0.07);
  --glow-1:      rgba(82,113,255,0.09);
  --glow-2:      rgba(255,255,255,0.035);
  --header-fade: rgba(9,10,13,0.94);
  --rail-bg:     rgba(16,16,22,0.42);
  --copy-line:   #2f323e;
  --card-shadow: none;
  --card-hover-shadow: none;
  --panel-shadow: 0 40px 110px -30px rgba(0,0,0,0.86), 0 0 0 1px rgba(255,255,255,0.04);
  --do-color:    #cdd7ff;
  --dont-bg:     rgba(220,90,80,0.12);
  --dont-color:  #f0a59c;

  /* 타이포 시스템 — Quiet Luxury / Editorial Fashion Archive
     display=Newsreader(세리프) · ui=Inter · kr=Pretendard
     배포본은 웹폰트 링크가 제거되므로 Inter/Newsreader 를 base64 로 내장한다. */
  --font-display: 'Newsreader', 'Times New Roman', serif;
  --font-ui: 'Inter', 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI",
             'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-kr: 'Pretendard', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic',
             -apple-system, sans-serif;
  --sans: var(--font-ui);
  --mono: var(--font-ui);
  --kr:   var(--font-kr);
  --code: var(--font-ui);
  --tracking-tight: -0.025em;
  --tracking-normal: -0.01em;
  --tracking-label: 0.12em;
  --ease: cubic-bezier(.22,.8,.28,1);
  --header-h: 58px;
  --sidebar-w: 380px;   /* 고정 상세 패널 */
  --toolbar-h: 52px;    /* 그리드 상단 카테고리 툴바 */
}

/* ── Bright (light) theme — 화이트 + 블루 (클린 디자인 스튜디오) ── */
:root[data-theme="light"] {
  --bg:      #f4f7ff;
  --bg-2:    #ffffff;
  --surface: #ffffff;
  --line:    rgba(24,44,96,0.09);
  --line-2:  rgba(24,44,96,0.15);
  --text-1:  #0e1526;
  --text-2:  #465069;
  --text-3:  #8b93a9;
  /* 다크에서 흰색(ivory)으로 쓰던 본문·제목은 밝은 테마에서 잉크 블랙으로 뒤집는다 */
  --ivory:       #0e1526;
  --line-strong: rgba(24,44,96,0.28);
  --muted-2:     #7d869c;
  --warm-gray:   #6b7285;
  --accent:      #1f5bff;
  --accent-soft: rgba(31,91,255,0.10);
  --accent-line: rgba(31,91,255,0.42);

  --cat-accent:  #1f5bff;
  --photo-bg:    #eef2fc;
  --hover:       rgba(31,91,255,0.06);
  --input-bg:    #ffffff;
  --input-bg-focus: #ffffff;
  --glow-1:      rgba(31,91,255,0.10);
  --glow-2:      rgba(31,91,255,0.035);
  --header-fade: rgba(255,255,255,0.92);
  --rail-bg:     rgba(255,255,255,0.72);
  --copy-line: rgba(24,44,96,0.22);
  --card-shadow: 0 12px 30px -14px rgba(28,50,110,0.16);
  --card-hover-shadow: 0 20px 46px -16px rgba(28,50,110,0.26), 0 0 0 1px var(--accent-line);
  --panel-shadow: 0 40px 100px -30px rgba(28,50,110,0.24), 0 0 0 1px rgba(24,44,96,0.06);
  --do-color:    #1a49dd;
  --dont-bg:     rgba(210,70,60,0.08);
  --dont-color:  #c0392b;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-weight: 400; letter-spacing: var(--tracking-normal);
  text-rendering: optimizeLegibility;
  color: var(--text-1);
  background: var(--bg);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .3s ease, color .3s ease;
}
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(1100px 700px at 50% 38%, var(--glow-1), transparent 60%),
    radial-gradient(900px 900px at 50% 120%, var(--glow-2), transparent 60%),
    var(--bg);
  pointer-events: none;
  transition: background .3s ease;
}

.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.hidden { display: none !important; }
mark { background: var(--accent-soft); color: var(--accent); border-radius: 2px; padding: 0 1px; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* ─── Header ─────────────────────────────────────────────── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 60;
  background: linear-gradient(180deg, var(--header-fade) 0%, transparent 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.header-inner {
  height: var(--header-h);
  padding: 0 22px;
  display: flex; align-items: center; gap: 18px;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ivory); flex-shrink: 0; white-space: nowrap; }
/* 회사 로고 — 브랜드 블루 원본 그대로 (아이덴티티는 채도를 유지) */
.brand-logo {
  height: 17px; width: auto; display: block; flex-shrink: 0;
  opacity: 1;
}
/* 로고와 제품명 사이 얇은 구분선 */
.brand-name {
  padding-left: 14px; margin-left: 2px;
  border-left: 1px solid var(--line);
}
.brand-h { height: 16px; width: auto; display: block; color: var(--text-1); }
.brand-name { font-family: var(--font-ui); font-size: 12px; font-weight: 500; letter-spacing: 0.01em; }

.header-search { position: relative; display: flex; align-items: center; flex: 1; max-width: 440px; margin: 0 auto; }
.search-wrap { position: relative; display: flex; align-items: center; width: 100%; }
.header-search input {
  width: 100%;
  height: 42px;
  padding: 0 36px 0 34px;
  font-size: 13px; font-family: var(--font-ui); font-weight: 400; letter-spacing: -0.01em;
  color: var(--text-1);
  background: var(--input-bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  outline: none;
  transition: border-color .18s, background .18s;
}
/* 브라우저 기본 검색 취소(×) 아이콘 숨김 — 커스텀 지우기 버튼과 중복 */
.header-search input::-webkit-search-cancel-button,
.header-search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.header-search input::placeholder { color: var(--muted-2); font-weight: 400; }
.header-search input:focus { border-color: var(--line-strong); background: var(--input-bg-focus); }
.search-icon { position: absolute; left: 2px; color: var(--text-3); display: flex; pointer-events: none; }
.search-wrap:focus-within .search-icon { color: var(--accent); }
.search-clear {
  position: absolute; right: 10px; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer;
  transition: background .12s, color .12s;
}
.search-clear:hover { background: var(--hover); color: var(--text-1); }

.header-count { font-family: var(--mono); font-size: 0.74rem; color: var(--text-3); flex-shrink: 0; white-space: nowrap; }

/* Theme toggle (top-right) */
.theme-toggle {
  display: inline-flex; flex-shrink: 0; align-items: center;
  border: 0; border-radius: 0; padding: 0; gap: 16px; background: transparent;
}
.tt-btn {
  border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--text-3);
  font-family: var(--font-ui); font-size: 9px; font-weight: 500; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 8px 0; border-radius: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: color .15s, border-color .15s;
}
.tt-btn svg { display: none; }
.tt-btn:hover { color: var(--text-1); }
.tt-btn[aria-pressed="true"] { color: var(--ivory); border-bottom-color: var(--ivory); background: transparent; }

/* 단일 테마 토글 버튼 (헤더 우측 ◐) */
.theme-btn {
  flex-shrink: 0; width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 0;
  background: transparent; color: var(--text-3); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .3s var(--ease);
}
.theme-btn:hover { color: var(--text-1); border-color: var(--accent-line); }
:root[data-theme="light"] .theme-btn svg { transform: rotate(180deg); }

/* autocomplete */
.autocomplete {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  margin: 0; padding: 6px; list-style: none;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: var(--panel-shadow);
  max-height: 340px; overflow-y: auto;
}
.ac-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; cursor: pointer; transition: background .12s; }
.ac-item:hover, .ac-item.active { background: var(--hover); }
/* 검색 결과 — 표준 영문이 메인, 현장 혼용어가 서브 */
.ac-term { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-ui); font-size: 0.88rem; font-weight: 500; letter-spacing: -0.01em; color: var(--ivory); }
.ac-en { margin-left: auto; font-family: var(--mono); font-size: 0.74rem; color: var(--text-3); }

/* ─── 3D stream stage ────────────────────────────────────── */
.stream-main { position: absolute; inset: 0; z-index: 1; transition: opacity .19s var(--ease); }
/* 3D ↔ Grid 전환 시 부드러운 페이드(하드 컷 방지) */
.stream-main.view-fading { opacity: 0; }
.stage {
  position: absolute; inset: 0;
  perspective: 2000px;   /* 배럴 곡률이 보이도록 원근 강화 */
  perspective-origin: 50% 50%;   /* 4행 원통: 상하 대칭 */
  cursor: grab;
  touch-action: none;
  overflow: hidden;
}
.stage.dragging { cursor: grabbing; }
.stage.dragging-y { cursor: ns-resize; }

.stream-travel {
  position: absolute; top: 46%; left: 50%;
  /* 전체를 축소(scale)해 토네이도를 멀리 놓은 듯 한눈에 보이게 한다 */
  transform: translate(-50%, -50%) translateY(var(--travel, 0px)) scale(0.52);   /* 4행 원통이 화면에 다 들어오도록 */
  transform-style: preserve-3d;
  will-change: transform;
}
.stream {
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-6deg) rotateY(var(--spin, 0deg));
  will-change: transform;
}

/* photo term card — 사진(상단) + 용어 정보(하단) */
.s-card {
  position: absolute; top: 0; left: 0;
  /* 사진 3:4(210×280) + 캡션 82px — Grid 와 같은 사진 비율이라 잘리지 않는다 */
  width: 210px; height: 362px;
  margin: -181px 0 0 -105px;
  padding: 0; border: none; background: none; cursor: pointer;
  transform-style: preserve-3d;
  transform: rotateY(var(--a)) translateZ(calc(var(--R, 360px) - var(--dz, 0px))) translateY(var(--y, 0px));
  transition: opacity .25s var(--ease), transform .5s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.s-card.s-dim { --dz: 90px; }
.s-card.s-dim .s-card-inner { filter: grayscale(0.55) brightness(0.55); }
/* 카드 박스 없이 — 썸네일 + 그 아래 텍스트만 (커머스 상품 목록 구조) */
.s-card-inner {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: transparent; border: none; box-shadow: none; border-radius: 0;
  transition: transform .22s var(--ease), filter .45s var(--ease);
}
.s-card:hover .s-card-inner,
.s-card:focus-visible .s-card-inner { transform: translateZ(28px) scale(1.04); }
.s-card:hover .s-photo, .s-card:focus-visible .s-photo { border-color: var(--line-strong); }
/* 선택(잠금)된 카드 */
.s-card.is-selected .s-photo { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(133,152,173,0.32); }
.s-card.is-selected .s-en { color: var(--ivory); }
.s-card:focus-visible { outline: none; }
.s-card:focus-visible .s-photo { outline: 2px solid var(--accent); outline-offset: 2px; }
.s-photo {
  position: relative; flex: 1; min-height: 0;
  background: var(--photo-bg); overflow: hidden;
  border: 1px solid transparent; border-radius: 0;
  transition: border-color .16s, background .16s;
}
.s-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 3D 원통 카드도 사진 칸을 3:4 로 고정 — 3:4 사진은 그대로, 4:5 사진은 좌우가 약 3%씩만 잘린다 */
.stream .s-photo { flex: none; aspect-ratio: 3 / 4; }
.stream .s-photo--full img { object-fit: contain; }
.s-noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-family: var(--mono); font-size: 0.7rem; }
/* 썸네일 아래 캡션 — 배경 없이 헤어라인 하나로만 구분 */
.s-info {
  flex-shrink: 0; display: flex; flex-direction: column; gap: 0;
  padding: 7px 0 0; text-align: left;
  /* 캡션 블록 높이만 2줄분으로 예약 — 남는 여백은 아래로 가고,
     표준어↔혼용어 간격(5px)은 항상 붙어 있게 한다 */
  min-height: 82px;
}
.s-cat { font-family: var(--sans); font-size: 0.54rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cat-accent); flex-shrink: 0; }
/* STANDARD EN — 메인(첫줄, 굵게) + 오른쪽 복사 아이콘 */
.s-en-row { display: flex; align-items: flex-start; gap: 6px; flex-shrink: 0; }
.s-en {
  flex: 1; min-width: 0;
  font-family: var(--font-ui); font-size: 17px; font-weight: 500; color: var(--ivory);
  letter-spacing: -0.02em; line-height: 1.35;
  word-break: keep-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.s-copy-inline {
  flex-shrink: 0; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--copy-line); border-radius: 6px; background: var(--input-bg); color: var(--text-2); cursor: pointer;
  /* 평소엔 숨기고 카드 호버·포커스에서만 노출 */
  opacity: 0; pointer-events: none;
  transition: opacity .14s, background .14s, color .14s, border-color .14s, transform .1s;
}
.s-card:hover .s-copy-inline,
.s-card:focus-within .s-copy-inline { opacity: 1; pointer-events: auto; }
.s-copy-inline:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.s-copy-inline:active { transform: scale(0.9); }
/* KOREAN MEANING — 표준 영문 아래 작게 */
.s-ko-mean { font-family: var(--kr); font-size: 0.78rem; font-weight: 600; color: var(--text-2); margin-top: 1px; line-height: 1.3; word-break: keep-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex-shrink: 0; }
/* 혼용어 — FIELD 라벨 + 값, 표준어 아래 5px */
.s-field-row {
  display: flex; align-items: baseline; gap: 6px;
  margin-top: 5px; min-width: 0;
}
.s-field-label {
  flex: 0 0 auto;
  font-family: var(--font-ui); font-size: 8px; font-weight: 500;
  letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--warm-gray);
}
.s-field {
  min-width: 0; text-align: left;
  font-family: var(--font-kr); font-size: 13.5px; font-weight: 400; color: var(--text-2);
  line-height: 1.4; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.empty-msg { position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); text-align: center; color: var(--text-2); font-size: 0.95rem; z-index: 2; }

.stream-hint {
  position: absolute; left: 0; right: 0; bottom: 22px; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-family: var(--sans); font-size: 0.74rem; letter-spacing: 0.03em;
  color: var(--text-3); pointer-events: none;
}
.stream-hint i { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); opacity: 0.6; }

.replay-intro {
  position: fixed; bottom: 22px; right: 24px; z-index: 6;
  font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.04em;
  color: var(--text-3); background: none; border: none; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
  transition: color .12s;
}
.replay-intro:hover, .replay-intro:focus-visible { color: var(--text-1); outline: none; }

/* ─── Category grid — 한 화면에 카드가 다 보이도록 5열 컴팩트 ── */
.cat-grid {
  position: absolute; inset: 0; z-index: 1;
  overflow-y: auto;
  /* 스크롤 컨테이너는 메인 영역을 꽉 채우고(→ 스크롤바 우측 끝),
     카드는 좌우 대칭 패딩으로 가운데 정렬 */
  top: var(--toolbar-h);
  padding: 24px max(24px, calc((100% - 1440px) / 2)) 24px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 32px 22px;
  align-content: start;
  animation: grid-in .32s var(--ease);
}
@keyframes grid-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.cat-grid .s-card {
  position: relative; margin: 0; width: 100%; height: auto;
  transform: none !important; opacity: 1 !important;
  /* 그리드는 평면 — 3D 원통용 preserve-3d 를 끄면 카드마다 합성 레이어가 생기지 않아
     클릭·스크롤 때 화면 갱신이 가벼워진다 */
  transform-style: flat;
}
/* 그리드 썸네일 — 사진 칸을 3:4 로 고정하고 꽉 채운다.
   3:4 사진은 그대로, 4:5 사진은 좌우가 약 3%씩 잘린다.
   가장자리의 확대 박스가 잘리는 사진(s-photo--full)만 위아래 여백을 두고 전체를 보여준다. */
.cat-grid .s-photo { flex: none; aspect-ratio: 3 / 4; }
.cat-grid .s-photo img { object-fit: cover; }
.cat-grid .s-photo--full img { object-fit: contain; }
.cat-grid .s-card.s-dim .s-card-inner { filter: none; }
.cat-grid .s-info { padding: 7px 0 0; }
.cat-grid .s-cat { font-size: 0.54rem; }
.cat-grid .s-en { font-size: 17px; }
.cat-grid .s-ko-mean { font-size: 0.72rem; }
.cat-grid .s-field { font-size: 13.5px; }
.cat-grid .s-expand { width: 24px; height: 24px; top: 8px; right: 8px; }

/* 봉제 현장 용어(field) 모드 — 16개가 한 화면에 다 보이도록 더 컴팩트하게 */
.main-area.field-mode .cat-grid { padding: 30px max(22px, calc((100% - 1360px) / 2)) 14px; gap: 10px; }
.main-area.field-mode .cat-grid .s-card { height: 174px; }
.main-area.field-mode .cat-grid .s-info { padding: 7px 0 0; }

/* ═══ App shell: 헤더 + 좌측 사이드바 + 메인 ═══════════════ */
.app-shell {
  position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
  z-index: 1; display: flex;
}
.sidebar {
  position: relative;
  flex-shrink: 0; width: var(--sidebar-w); height: 100%;
  overflow-y: auto; overflow-x: visible;
  padding: 24px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-cats { flex: 1; min-height: 0; }
.side-title {
  font-family: var(--sans); font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-3);
  padding: 6px 12px 10px;
}
.side-divider { height: 1px; background: var(--line); margin: 10px 6px; }

/* ─── 좌측 상단 메뉴 아이콘 (가이드 + 카테고리) ─────────────── */
.side-menubar { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.menu-btn {
  flex-shrink: 0; width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 0; padding: 0;
  background: transparent; color: var(--text-3); cursor: pointer;
  transition: color .15s;
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { color: var(--ivory); background: transparent; }
.menu-current {
  font-family: var(--kr); font-size: 0.82rem; font-weight: 700; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu-pop {
  position: absolute; z-index: 60; top: calc(100% + 8px); left: 0; width: 248px;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--bg-2);
  padding: 10px; box-shadow: var(--panel-shadow);
  display: flex; flex-direction: column; gap: 4px; max-height: 78vh; overflow-y: auto;
}

/* ─── 3D 카드 호버 정보 패널 (goodflix LA LA LAND 스타일, 크게) ── */
/* 고정 슬롯 그리드 — 각 항목이 항상 같은 자리를 차지하고 내용만 바뀐다.
   행 높이를 명시해 두므로 어떤 카드를 호버해도 위치가 흔들리거나 겹치지 않는다. */
/* 용어집 매뉴얼 — 정보 전달 우선의 심플·모던 구성.
   플랫한 사각 면(radius 4px), 그림자 없음, 액센트는 카테고리 한 곳에만.
   타이포 11 / 13 / 15 / 30px 4단 위계. */
.hover-panel {
  /* 사이드바 패딩(24px)만 쓰고 패널 자체 여백은 두지 않는다 —
     사진을 없앤 뒤 텍스트가 패널 상단에서 바로 시작하도록. */
  padding: 0 0 8px; min-height: 0; flex: 1;
  display: grid;
  /* 값마다 고정 높이를 주어 호버 시 Y 위치가 고정되고,
     항목 사이 간격은 row-gap 하나로 균일하게 유지된다. */
  grid-template-rows: auto auto auto auto auto;
  row-gap: 22px;
  align-content: start;
}
/* 그리드 자식의 기본 min-width:auto 를 풀어 준다 —
   풀지 않으면 긴 표준 용어가 행을 넓혀 우측 복사 아이콘이 패널 밖으로 잘린다 */
.hover-panel > * { min-width: 0; }
/* 표준 용어 블록 — 카테고리(라벨) + 표준 용어(값), 다른 소항목과 동일 구조.
   값 슬롯은 31px 고정이라 글자 크기가 줄어도 아래 항목이 밀리지 않는다. */
.hp-head .hp-row { height: 31px; }
/* 소항목 블록 — 라벨과 내용이 한 덩어리로 움직인다 */
.hp-block { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.hp-block .hp-slabel { align-self: flex-start; margin-bottom: 7px; }
/* 첫 화면(선택 전) — 항목 라벨과 슬롯 높이는 그대로 두고 내용만 비운다 */

/* 1. 카테고리 — 시스템 내 유일한 액센트 */
.hp-cat {
  /* 다른 소제목과 동일한 색·크기 (액센트는 선택 상태에만 남긴다) */
  font-family: var(--font-ui); font-size: 8px; font-weight: 500; line-height: 1;
  letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-3);
  align-self: start;
  /* 다른 소제목과 동일한 라벨 → 값 간격 */
  margin-bottom: 7px;
  /* 내용이 비어도(첫 화면) 라벨 높이는 유지 → 아래 항목이 위로 밀리지 않는다 */
  min-height: 8px;
}
/* 2. 표준 용어 */
.hp-title {
  font-family: var(--font-display); font-size: 26px; font-weight: 400;
  line-height: 1.08; letter-spacing: -0.03em; color: var(--ivory);
  margin: 0; word-break: keep-all;
  /* 글자 크기가 줄어도 슬롯 높이는 그대로 → 아래 항목 간격이 흔들리지 않는다 */
  height: 100%; display: flex; align-items: flex-start;
  /* 긴 용어는 잘라내지 않고 JS 가 글자 크기를 줄여 맞춘다 */
  overflow: hidden; text-overflow: clip;
}
/* 3. 현장어 — 소항목 값 */
.hp-meta { display: flex; align-items: center; gap: 9px; overflow: hidden; height: calc(14px * 1.45); }
.hp-alias-v {
  font-family: var(--font-kr); font-size: 14px; font-weight: 400; line-height: 1.45;
  letter-spacing: -0.015em; color: var(--text-1); white-space: nowrap;
  height: calc(14px * 1.45);              /* 1줄 예약 */
}
/* 값 구분자 — 가는 세로 헤어라인 */
.hp-alias-sep { width: 1px; height: 12px; background: var(--line-2); display: inline-block; }
/* 소항목 라벨 (Field Term · Meaning · Tech Pack Example) — 전부 동일 문법.
   라틴 대문자만 쓰므로 mono 로도 항상 또렷하게 렌더링된다. */
.hp-slabel {
  font-family: var(--font-ui); font-size: 8px; font-weight: 500; line-height: 1;
  letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-3);
  align-self: start;
}
/* 4. 정의 — 본문 (가독성 우선) */
.hp-desc {
  font-family: var(--font-kr); font-size: 14px; font-weight: 400; line-height: 1.6;
  letter-spacing: -0.015em; color: var(--text-1); margin: 0; word-break: keep-all;
  height: calc(14px * 1.6 * 3);        /* 3줄 예약 */
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
/* 5. 예문 — 얇은 테두리 박스 + 우측 상단 복사 버튼 */
.hp-ex-box { position: relative; }
/* 값 + 우측 복사 아이콘 행 */
.hp-row { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.hp-row > :first-child { flex: 1; min-width: 0; }
.hp-row .hp-title { max-width: 100%; }
.hp-copy {
  flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 1px solid transparent; border-radius: 3px;
  background: transparent; color: var(--muted-2); cursor: pointer;
  opacity: 0; transition: opacity .14s, color .14s, border-color .14s;
}
.hover-panel.hp-live .hp-copy { opacity: 1; }
/* 현장 용어 줄은 값 높이(1줄)에 맞춰 고정 — 복사 버튼이 블록을 늘리지 않게 */
#hp-alias-block .hp-row { height: calc(14px * 1.45); align-items: center; }
#hp-alias-block .hp-copy { margin-top: 0; width: 18px; height: 18px; }
.hp-copy:hover { color: var(--ivory); border-color: var(--line-2); }
.hp-copy:active { transform: scale(0.92); }
.hp-copy.is-copied { color: var(--accent); border-color: var(--accent); }
.hp-ex {
  font-family: var(--font-ui); font-size: 14px; font-weight: 400; line-height: 1.6;
  letter-spacing: -0.005em; max-width: 100%;
  color: var(--text-1); word-break: break-word;
  height: calc(14px * 1.6 * 4);        /* 4줄 예약 */
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.hp-ex-copy {
  padding: 0; border: 0; background: transparent; cursor: pointer;
  color: var(--text-3); font-family: var(--font-ui); font-size: 8px; font-weight: 500;
  letter-spacing: 0.10em; text-transform: uppercase;
  transition: color .14s;
}
.hp-ex-copy:hover { color: var(--ivory); }
/* 선택 잠금 표시 */

/* 빈 항목도 슬롯은 유지 (display:none 대신 투명 처리) */
.hp-invisible { visibility: hidden; }


.side-nav { display: flex; flex-direction: column; gap: 2px; }
/* hidden 속성이 display:flex 에 눌리지 않도록 — 현장 용어가 0개일 때 메뉴에서 감춘다 */
.side-nav-item[hidden] { display: none !important; }
.side-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: none; background: transparent; cursor: pointer;
  border-radius: 10px; text-align: left; color: var(--text-2);
  font-family: var(--kr); font-size: 0.84rem; font-weight: 600; line-height: 1.3;
  word-break: keep-all;
  transition: background .15s, color .15s;
}
.side-nav-item svg { flex-shrink: 0; opacity: 0.85; }
.side-nav-item span { flex: 1; }
.side-nav-item:hover { background: var(--hover); color: var(--text-1); }
.side-nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--text-1); }
.side-nav-item[aria-current="true"] svg { color: var(--accent); opacity: 1; }

/* ─── Category rail (사이드바 내부) ───────────────────────── */
/* 좌측 상단 카테고리 바 — 가로 배치 (항상 노출) */
.side-cats-top {
  margin: 0; padding: 30px 0 18px; border-bottom: 1px solid var(--line);
  /* 메뉴 아이콘(좌) → 카테고리(우) — 같은 행 축에 정렬 */
  display: flex; align-items: center; gap: 16px;
}
.side-cats-top .cat-rail { flex: 1; min-width: 0; }
.side-cats-top .cat-rail {
  flex-direction: row; flex-wrap: wrap; gap: 7px 14px;
  overflow: visible;
}
.side-cats-top .cat-item {
  flex: 0 0 auto; gap: 5px; padding: 0;
  border: 0; border-radius: 0; background: transparent;
  align-items: center; line-height: 1;
}
.side-cats-top .cat-rail { align-items: center; }
.side-cats-top .cat-item::before { display: none; }   /* 세로 액센트 바 제거 */
.side-cats-top .cat-item .ci-label {
  flex: 0 0 auto; font-family: var(--font-ui);
  font-size: 9px; font-weight: 500; letter-spacing: 0.02em;
}
/* 상단 카테고리 탭은 시안 스펙(10px/500) 유지 — 아래 일반 rail 규칙보다 우선 */
.side-cats-top .cat-item[aria-selected] .ci-label { font-weight: 500; }
.side-cats-top .cat-item .ci-count {
  width: auto; font-family: var(--font-ui); font-size: 9px; font-weight: 500;
}
.side-cats-top .cat-item:hover,
.side-cats-top .cat-item[aria-selected="true"] { background: transparent; color: var(--ivory); }
.side-cats-top .cat-item[aria-selected="true"] .ci-label,
.side-cats-top .cat-item[aria-selected="true"] .ci-count { color: var(--ivory); }

.cat-rail { display: flex; flex-direction: column; gap: 1px; }
.cat-item {
  position: relative;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  border: none; background: transparent; cursor: pointer;
  border-radius: 9px; text-align: left;
  color: var(--text-2);
  font-family: var(--kr);
  transition: background .16s, color .16s;
}
/* 하위 항목 — 위 KNOWLEDGE 항목(.side-nav-item)과 폰트 크기 통일 */
.cat-item .ci-label { flex: 1; min-width: 0; font-size: 0.84rem; font-weight: 600; letter-spacing: -0.005em; }
/* 숫자 — 26px 고정 열, 우측 정렬, tabular-nums(자릿수 무관 정렬) */
.cat-item .ci-count {
  flex: none; width: 26px; text-align: right;
  font-family: var(--sans); font-size: 0.8rem; font-weight: 600; color: var(--text-3);
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
  transition: color .16s;
}
.cat-item:hover { background: var(--hover); color: var(--text-1); }
.cat-item[aria-selected="true"] { background: var(--accent-soft); color: var(--text-1); }
.cat-item[aria-selected="true"] .ci-label { font-weight: 600; }
.cat-item[aria-selected="true"]::before {
  content: ''; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 3px; border-radius: 2px; background: var(--accent);
}
.cat-item[aria-selected="true"] .ci-count { color: var(--accent); font-weight: 700; }

/* Mobile: horizontal scrollable chips under the search bar */
.cat-chips { display: none; }
.cat-chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--line-2); background: var(--input-bg);
  border-radius: 999px; cursor: pointer;
  color: var(--text-2); font-family: var(--kr); font-size: 0.8rem; font-weight: 500;
  white-space: nowrap;
  transition: background .16s, color .16s, border-color .16s;
}
.cat-chip .ci-count { font-family: var(--mono); font-size: 0.68rem; color: var(--text-3); }
.cat-chip[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-chip[aria-selected="true"] .ci-count { color: rgba(255,255,255,0.85); }

/* ─── Detail side panel ──────────────────────────────────── */
.panel-scrim {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .3s ease;
}
:root[data-theme="light"] .panel-scrim { background: rgba(20,22,40,0.32); }
.panel-scrim.show { opacity: 1; }
.term-panel {
  position: fixed; top: 50%; left: 50%;
  width: min(1060px, 95vw); max-height: 88vh;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  box-shadow: var(--panel-shadow);
  z-index: 1001;
  overflow: hidden;
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -48%) scale(0.9);
  transition: transform .42s var(--ease), opacity .3s ease;
  display: flex; flex-direction: column;
}
.term-panel.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.panel-close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--hover); border: 1px solid var(--line-2);
  border-radius: 50%; color: var(--text-1); cursor: pointer; z-index: 3;
  backdrop-filter: blur(6px);
  transition: background .14s, color .14s, border-color .14s;
}
.panel-close:hover { background: var(--accent-soft); color: var(--accent); }

/* 사진(왼쪽) · 정보(오른쪽) 2단 — 한눈에 상세가 보이도록 */
.panel-body { display: flex; flex-direction: row; overflow: hidden; max-height: 88vh; }
.p-media {
  flex: 0 0 46%; align-self: stretch;
  background: var(--photo-bg);
  border-right: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.p-media img { width: 100%; height: 100%; max-height: 88vh; object-fit: contain; display: block; }
.p-info { flex: 1 1 auto; min-width: 0; min-height: 0; overflow-y: auto; padding: 30px 34px 36px; }

/* 좁은 화면(모바일)에선 다시 사진 위·정보 아래로 */
@media (max-width: 760px) {
  .panel-body { flex-direction: column; }
  .p-media { flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--line); max-height: 38vh; }
  .p-media img { height: auto; max-height: 38vh; }
}

.p-cat { font-family: var(--sans); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--cat-accent); margin-bottom: 10px; }
.p-term { font-family: var(--kr); font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text-1); line-height: 1.12; word-break: keep-all; margin-bottom: 6px; }
/* 상세 패널 표준 단어 + 복사 아이콘 */
.p-term-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.p-term-row .p-term { margin-bottom: 0; flex: 1; min-width: 0; }
.p-term-row .p-copy { position: static; flex-shrink: 0; margin-top: 5px; }
.p-en { font-family: var(--mono); font-size: 0.84rem; color: var(--text-2); margin-bottom: 22px; }
.p-block { margin-top: 20px; }
.p-label { font-family: var(--sans); font-size: 0.64rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.p-text { font-size: 0.92rem; color: var(--text-2); line-height: 1.65; word-break: keep-all; }
.p-example { font-family: var(--kr); font-size: 0.92rem; color: var(--text-1); line-height: 1.65; background: var(--hover); border-left: 2px solid var(--accent); border-radius: 0 8px 8px 0; padding: 11px 14px; }
.p-related { display: flex; flex-wrap: wrap; gap: 7px; }
.p-related button { font-family: var(--sans); font-size: 0.8rem; color: var(--text-2); background: var(--hover); border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; cursor: pointer; transition: color .14s, border-color .14s, background .14s; }
.p-related button:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.p-dodont { display: grid; gap: 8px; }
.p-do, .p-dont { font-size: 0.86rem; line-height: 1.55; padding: 10px 13px; border-radius: 8px; word-break: keep-all; }
.p-do { background: var(--accent-soft); color: var(--do-color); }
.p-dont { background: var(--dont-bg); color: var(--dont-color); }
.p-do b, .p-dont b { font-weight: 700; }
.p-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.p-tag { font-family: var(--mono); font-size: 0.72rem; color: var(--text-3); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; }
.p-updated { font-family: var(--mono); font-size: 0.72rem; color: var(--text-3); }
.p-divider { height: 1px; background: var(--line); margin: 22px 0; }

/* ═══ Main area (사이드바 오른쪽 콘텐츠 영역) ═══════════════ */
.main-area { position: relative; flex: 1; min-width: 0; overflow: hidden; }
/* 헤더 우측 도구 — 검색바 오른쪽에 보기 방식 + 테마 */
.header-tools { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto; }
/* 3D/Grid 는 용어집에서만, 테마 토글은 모든 모드에서 노출 */
body.guide-mode .view-toggle,
body.field-mode .view-toggle { display: none; }

/* ─── Responsive ─────────────────────────────────────────── */
/* 열 수·좁은 화면 규칙은 파일 하단 「2026-09 UI 개선」 블록에서 관리한다 */
@media (max-width: 720px) {
  .brand-name { display: none; }
  .stream-hint { font-size: 0.68rem; gap: 9px; }
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .term-panel { width: 94vw; }
  .p-media, .p-media img { max-height: 38vh; }
  .p-info { padding: 24px 22px 30px; }
}
@media (max-width: 460px) {
  .cat-grid { grid-template-columns: 1fr; padding: 56px 16px 24px; }
}

/* ─── Reduced motion: no spinning 3D, use scrollable grid ── */
@media (prefers-reduced-motion: reduce) {
  body { overflow: auto; }
  .stage, .stream-hint { display: none; }
  .s-card { transition: none; }
}

/* ═══ Tutorial button + view toggle (header) ═══════════════ */
.tutorial-btn {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  border: 1px solid var(--accent-line); border-radius: 999px;
  padding: 8px 15px; background: var(--accent-soft); color: var(--text-1);
  font-family: var(--sans); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.tutorial-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.tutorial-btn svg { flex-shrink: 0; }
.tt-btn svg { flex-shrink: 0; }

/* ═══ 카드: 이미지 없는 현장 용어 (일본식 → 표준) ═══════════ */
.s-fieldmark {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; width: 100%; height: 100%; padding: 12px; text-align: center;
}
.s-fieldmark b  { font-family: var(--kr); font-size: 1.02rem; font-weight: 700; color: var(--text-2); }
.s-fieldmark i  { font-style: normal; color: var(--accent); font-size: 1.0rem; line-height: 1; }
.s-fieldmark em { font-style: normal; font-family: var(--kr); font-size: 1.06rem; font-weight: 800; color: var(--text-1); }

/* ═══ Tutorial (실무 가이드) — 메인 영역 내부 ═══════════════ */
.tutorial {
  position: absolute; inset: 0; z-index: 8;
  background: transparent;   /* 뒤의 커서 인터랙티브 점 배경이 비치도록 */
  animation: tut-in .28s var(--ease);
}
@keyframes tut-in { from { opacity: 0; } to { opacity: 1; } }
/* 스크롤은 tut-body가 메인 영역 전체 폭에서 담당(→ 스크롤바 우측 끝),
   머리말·본문은 max() 패딩으로 가운데 1180px 폭에 정렬 (그리드와 동일) */
.tut-inner { height: 100%; display: flex; flex-direction: column; padding: 30px 0 0; }
.tut-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 0 max(34px, calc((100% - 1180px) / 2)); }
.tut-kicker { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.tut-title { font-family: var(--kr); font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text-1); }
.tut-lede { max-width: 720px; margin-top: 8px; font-size: 0.88rem; line-height: 1.65; color: var(--text-2); word-break: keep-all; }
.tut-close {
  flex-shrink: 0; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--input-bg); color: var(--text-2);
  cursor: pointer; transition: background .15s, color .15s;
}
.tut-close:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.tut-tabs { display: flex; gap: 8px; margin: 22px 0 0; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tut-tab {
  border: none; background: none; cursor: pointer;
  font-family: var(--kr); font-size: 0.88rem; font-weight: 700; color: var(--text-3);
  padding: 10px 14px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tut-tab span { font-family: var(--mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.08em; color: var(--text-3); margin-left: 5px; }
.tut-tab:hover { color: var(--text-1); }
.tut-tab[aria-selected="true"] { color: var(--text-1); border-bottom-color: var(--accent); }
.tut-tab[aria-selected="true"] span { color: var(--accent); }

.tut-body { flex: 1; overflow-y: auto; padding: 24px max(34px, calc((100% - 1180px) / 2)) 60px; }

/* process cards */
.tut-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.tut-card {
  text-align: left; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: var(--surface); cursor: pointer; padding: 0;
  box-shadow: var(--card-shadow);
  opacity: 0; transform: translateY(10px);
  animation: tut-rise .4s var(--ease) forwards;
  transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
@keyframes tut-rise { to { opacity: 1; transform: none; } }
.tut-card:hover { transform: translateY(-4px); border-color: var(--accent-line); box-shadow: var(--card-hover-shadow); }
.tut-card-head { display: flex; justify-content: space-between; padding: 12px 15px 6px; font-family: var(--mono); }
.tc-num { font-size: 0.68rem; color: var(--text-3); }
.tc-iso { font-size: 0.66rem; letter-spacing: 0.06em; color: var(--accent); font-weight: 600; }
.tut-fig {
  margin: 4px 10px;
  background:
    linear-gradient(rgba(22,21,15,0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22,21,15,0.055) 1px, transparent 1px),
    #FCFBF8;
  background-size: 22px 22px;
  border: 1px solid rgba(22,21,15,0.10); border-radius: 8px; padding: 10px;
}
.tut-fig svg { display: block; width: 100%; height: auto; }
.tut-card-meta { padding: 8px 15px 15px; display: flex; flex-direction: column; gap: 2px; }
/* 표준 영어 = 메인 제목, 혼용(현장) 한국어 = 소제목 (용어집 카드와 동일 위계) */
.tc-en { font-family: var(--kr); font-size: 1.02rem; font-weight: 700; color: var(--text-1); letter-spacing: -0.01em; }
.tc-ko { font-family: var(--kr); font-size: 0.78rem; font-weight: 500; color: var(--text-3); margin-top: 1px; }

/* guide table */
.tut-note { font-family: var(--mono); font-size: 0.7rem; color: var(--text-3); margin-bottom: 14px; }
.tut-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.tut-table { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 560px; }
.tut-table th {
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.14em; text-align: left;
  color: var(--text-3); background: var(--bg-2);
  padding: 13px 18px; border-bottom: 1px solid var(--line-2); font-weight: 500;
}
.tut-table td { padding: 13px 18px; border-bottom: 1px solid var(--line); font-size: 0.86rem; color: var(--text-1); vertical-align: top; }
.tut-table tr:last-child td { border-bottom: 0; }
.tut-table tr:hover td { background: var(--hover); }
.tg-rec { font-weight: 700; color: var(--accent); white-space: nowrap; }
.tg-why { color: var(--text-2); font-size: 0.82rem; }

/* tutorial modal */
.tut-scrim {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 40px 18px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .22s ease;
}
.tut-scrim.show { opacity: 1; }
:root[data-theme="light"] .tut-scrim { background: rgba(20,22,40,0.4); }
.tut-modal {
  width: 100%; max-width: 760px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: var(--panel-shadow);
  animation: tut-pop .3s var(--ease);
}
@keyframes tut-pop { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: none; } }
.tm-head { display: flex; justify-content: space-between; gap: 16px; padding: 26px 28px 18px; border-bottom: 1px solid var(--line-2); }
.tm-iso { font-family: var(--mono); font-size: 0.68rem; color: var(--accent); font-weight: 600; letter-spacing: 0.08em; margin-bottom: 6px; }
.tm-ko { font-family: var(--kr); font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; color: var(--text-1); }
.tm-en { font-family: var(--mono); font-size: 0.76rem; color: var(--text-3); margin-top: 4px; }
.tm-head-act { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.tm-yt {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--input-bg); color: #e0332a;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s;
}
.tm-yt:hover, .tm-yt:focus-visible { background: #ff0000; color: #fff; border-color: #ff0000; outline: none; }
.tm-close {
  flex-shrink: 0; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--input-bg); color: var(--text-2);
  cursor: pointer; transition: background .15s, color .15s;
}
.tm-close:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.tm-body { padding: 20px 28px 30px; }
.tut-figtabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tut-figtab {
  font-family: var(--mono); font-size: 0.7rem; padding: 6px 13px;
  border: 1px solid var(--line-2); background: var(--input-bg); color: var(--text-2);
  border-radius: 20px; cursor: pointer; transition: all .15s;
}
.tut-figtab:hover { border-color: var(--accent-line); color: var(--text-1); }
.tut-figtab.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tut-fig-lg { margin: 0; padding: 16px; }
.tut-fig-lg svg { max-height: 420px; }
.tm-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-family: var(--mono); font-size: 0.66rem; color: rgba(22,21,15,0.55); }
.tm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tm-legend i { width: 15px; height: 3px; border-radius: 2px; display: inline-block; }
.tm-label {
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-3); margin: 22px 0 9px; display: flex; align-items: center; gap: 10px;
}
.tm-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.tm-specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tm-specs dl { padding: 11px 14px; border-right: 1px solid var(--line); }
.tm-specs dl:last-child { border-right: 0; }
.tm-specs dt { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.12em; color: var(--text-3); margin-bottom: 3px; }
.tm-specs dd { font-size: 0.84rem; font-weight: 600; color: var(--text-1); }
.tm-text { font-size: 0.9rem; line-height: 1.7; color: var(--text-1); }
.tm-uses { display: flex; gap: 7px; flex-wrap: wrap; }
.tm-use { font-size: 0.78rem; padding: 5px 12px; background: var(--hover); border: 1px solid var(--line); border-radius: 20px; color: var(--text-1); }
.tm-defect { font-size: 0.78rem; padding: 5px 12px; border-radius: 20px; color: var(--dont-color); background: var(--dont-bg); border: 1px solid var(--dont-bg); font-weight: 500; }
.tm-tip { background: var(--hover); border-left: 3px solid var(--accent); padding: 11px 15px; font-size: 0.84rem; line-height: 1.65; color: var(--text-2); border-radius: 0 8px 8px 0; }

/* ═══ 봉제 기계 애니메이션 (봉제도감 이식) ══════════════════ */
.mech { --cy: .9s; }
.a-needle { animation: tut-nd var(--cy) cubic-bezier(.55,0,.45,1) infinite; }
@keyframes tut-nd { 0%,100% { transform: translateY(0); } 38%,54% { transform: translateY(26px); } }
.a-trail { animation: tut-tr var(--cy) cubic-bezier(.4,0,.3,1) infinite; }
@keyframes tut-tr { 0%,56% { transform: translateX(0); } 88%,100% { transform: translateX(-56px); } }
.a-swing { animation: tut-sw calc(var(--cy)*2) cubic-bezier(.55,0,.45,1) infinite; }
@keyframes tut-sw { 0%,100% { transform: translateX(-11px); } 50% { transform: translateX(11px); } }
.a-wheel { animation: tut-rot var(--cy) linear infinite; transform-origin: center; }
@keyframes tut-rot { to { transform: rotate(360deg); } }
.a-fill { animation: tut-fb 2s cubic-bezier(.3,0,.4,1) infinite; }
@keyframes tut-fb { 0% { clip-path: inset(0 100% 0 0); } 58%,100% { clip-path: inset(0 0 0 0); } }
.fast { --cy: .34s; }

/* tutorial responsive */
@media (max-width: 980px) { .tut-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) {
  .tut-inner { padding: 22px 0 0; }
  .tut-head { padding: 0 18px; }
  .tut-body { padding-left: 18px; padding-right: 18px; }
  .tut-title { font-size: 1.3rem; }
  .tut-grid { grid-template-columns: 1fr; }
  .tutorial-btn { order: 2; }
  .theme-toggle { order: 2; }
}

/* ═══ 스크롤바 (Grid·Tutorial·패널) — 카드를 가리지 않게 ═════ */
.cat-grid, .tut-body, .panel-body, .autocomplete, .cat-rail, .tut-scrim {
  scrollbar-width: thin;                       /* Firefox */
  scrollbar-color: var(--line-2) transparent;
  scrollbar-gutter: stable;                    /* 스크롤바 자리 미리 확보 */
}
.cat-grid::-webkit-scrollbar, .tut-body::-webkit-scrollbar,
.panel-body::-webkit-scrollbar, .autocomplete::-webkit-scrollbar,
.cat-rail::-webkit-scrollbar, .tut-scrim::-webkit-scrollbar { width: 10px; }
.cat-grid::-webkit-scrollbar-track, .tut-body::-webkit-scrollbar-track,
.panel-body::-webkit-scrollbar-track, .autocomplete::-webkit-scrollbar-track,
.cat-rail::-webkit-scrollbar-track, .tut-scrim::-webkit-scrollbar-track { background: transparent; }
.cat-grid::-webkit-scrollbar-thumb, .tut-body::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb, .autocomplete::-webkit-scrollbar-thumb,
.cat-rail::-webkit-scrollbar-thumb, .tut-scrim::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 99px;
  border: 3px solid transparent;               /* 가장자리 여백 → 얇아 보임 */
  background-clip: padding-box;
}
.cat-grid:hover::-webkit-scrollbar-thumb, .tut-body:hover::-webkit-scrollbar-thumb,
.panel-body:hover::-webkit-scrollbar-thumb, .tut-scrim:hover::-webkit-scrollbar-thumb {
  background: var(--text-3); background-clip: padding-box;
}

/* ═══════════════════════════════════════════════════════════
   UI 컴포넌트 추가 (21st.dev · skiper-ui · smoothUI 이식)
   복사 버튼 · 커맨드 팔레트 · 스크램블 · 토스트 · 카드 확장 · 툴팁
   ═══════════════════════════════════════════════════════════ */

/* div[role=button] 로 바뀐 카드도 버튼처럼 동작
   (포커스 링은 썸네일에만 — 위 .s-card:focus-visible .s-photo 규칙 사용) */
.s-card { cursor: pointer; }

/* ─── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  z-index: 120; pointer-events: none;
  max-width: 84vw; padding: 11px 18px;
  background: var(--bg-2); color: var(--text-1);
  border: 1px solid var(--line-2); border-radius: 999px;
  box-shadow: var(--panel-shadow);
  font-family: var(--kr); font-size: 0.84rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  opacity: 0; transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast::before { content: '✓'; color: var(--accent); font-weight: 800; }
.toast[data-kind="err"]::before { content: '✕'; color: var(--dont-color); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ─── Copy button (패널 내 표준어·예문) ───────────────────── */
.p-copyable { position: relative; padding-right: 44px; }
.p-copy {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--input-bg); color: var(--text-3); cursor: pointer;
  transition: background .14s, color .14s, border-color .14s, transform .1s;
}
.p-copy:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.p-copy:active { transform: scale(0.62); }

/* ─── 툴팁 (variant 칩 → 표준어) ──────────────────────────── */
.p-chip {
  display: inline-block; margin: 2px 3px 0 0; padding: 2px 9px;
  font-family: var(--mono); font-size: 0.74rem; font-weight: 500;
  color: var(--dont-color); background: var(--dont-bg);
  border-radius: 6px;
}
.has-tip { position: relative; cursor: help; }
.has-tip::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  white-space: nowrap; z-index: 30;
  padding: 6px 10px; border-radius: 7px;
  background: var(--text-1); color: var(--bg);
  font-family: var(--kr); font-size: 0.72rem; font-weight: 600;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.has-tip::before {
  content: ''; position: absolute; left: 50%; bottom: calc(100% + 3px); transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--text-1);
  opacity: 0; z-index: 30; transition: opacity .15s;
}
.has-tip:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.has-tip:hover::before { opacity: 1; }

/* ─── 카드 확장 (그리드 뷰: 인플레이스 정의 미리보기) ────────── */
.s-expand { display: none; }
.cat-grid .s-card { position: relative; }
.cat-grid .s-expand {
  display: inline-flex; align-items: center; justify-content: center;
  position: absolute; top: 10px; right: 10px; z-index: 4;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text-2);
  cursor: pointer; transition: background .15s, color .15s, transform .2s var(--ease);
  box-shadow: 0 4px 14px -6px rgba(0,0,0,0.5);
}
.cat-grid .s-expand:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.cat-grid .s-card.expanded .s-expand { transform: rotate(180deg); }
.s-more {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 20px 18px 16px;
  background: var(--surface);
  border-radius: inherit;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .24s var(--ease), transform .24s var(--ease);
}
.cat-grid .s-card.expanded .s-more { opacity: 1; transform: none; pointer-events: auto; }
.s-more-label { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cat-accent); margin-bottom: 8px; }
.s-more-def { font-family: var(--kr); font-size: 0.9rem; line-height: 1.6; color: var(--text-1); overflow-y: auto; flex: 1; }
.s-more-en { font-family: var(--mono); font-size: 0.78rem; color: var(--text-2); margin-top: 10px; }
.s-more-actions { display: flex; gap: 8px; margin-top: 14px; }
.s-copy, .s-detail {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  font-family: var(--kr); font-size: 0.76rem; font-weight: 700;
  border: 1px solid var(--line-2); background: var(--input-bg); color: var(--text-1);
  transition: background .14s, color .14s, border-color .14s;
}
.s-copy:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.s-detail:hover { border-color: var(--accent-line); color: var(--accent); }

/* ─── Command palette (⌘K) ───────────────────────────────── */
.cmdk { position: fixed; inset: 0; z-index: 110; }
.cmdk-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity .2s; }
:root[data-theme="light"] .cmdk-scrim { background: rgba(20,22,40,0.34); }
.cmdk.show .cmdk-scrim { opacity: 1; }
.cmdk-panel {
  position: absolute; top: 14vh; left: 50%; transform: translateX(-50%) translateY(-10px) scale(.98);
  width: min(600px, 92vw);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: var(--panel-shadow); overflow: hidden;
  opacity: 0; transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.cmdk.show .cmdk-panel { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.cmdk-inputwrap { display: flex; align-items: center; gap: 11px; padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.cmdk-input { flex: 1; border: none; background: none; outline: none; font-family: var(--kr); font-size: 1.02rem; font-weight: 500; color: var(--text-1); }
.cmdk-input::placeholder { color: var(--text-3); font-weight: 400; }
.cmdk-esc { font-family: var(--mono); font-size: 0.6rem; color: var(--text-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 6px; }
.cmdk-list { list-style: none; margin: 0; padding: 8px; max-height: 46vh; overflow-y: auto; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 10px; cursor: pointer; }
.cmdk-item.active { background: var(--accent-soft); }
.cmdk-ko { font-family: var(--font-ui); font-size: 0.92rem; font-weight: 600; letter-spacing: -0.01em; color: var(--ivory); }
.cmdk-en { font-family: var(--font-kr); font-size: 0.76rem; color: var(--text-2); }
.cmdk-cat { margin-left: auto; font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.06em; color: var(--text-3); }
.cmdk-item.active .cmdk-cat { color: var(--accent); }
.cmdk-empty { padding: 26px; text-align: center; color: var(--text-3); font-family: var(--mono); font-size: 0.82rem; }
.cmdk-foot { display: flex; gap: 18px; padding: 11px 18px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 0.66rem; color: var(--text-3); }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }
.cmdk-foot kbd, .cmdk-esc { font-family: var(--mono); }
.cmdk-foot kbd { border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px; color: var(--text-2); }

/* ─── Interactive dot field (Grid 뷰 배경) ────────────────── */
.dot-field {
  position: absolute; inset: 0; z-index: 0;
  pointer-events: none;
  opacity: 0; transition: opacity .4s var(--ease);
}
.dot-field.on { opacity: 1; }

/* 사이드바 GUIDE 네비가 탭을 제어하므로 Tutorial 내부 탭바는 숨김 */
.tut-tabs { display: none; }
.tut-body { padding-top: 8px; }

/* ═══ 표준어=제목, 현장어=보조 (카드·검색·상세) ═══════════════ */
/* 자동완성: 표준어 위주 + '현장어로 검색됨' 보조 */
.ac-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
/* 혼용어 — 같은 줄 오른쪽 끝 */
.ac-field { margin-left: auto; padding-left: 12px; font-family: var(--font-kr); font-size: 0.76rem; color: var(--text-3); white-space: nowrap; }

/* 상세: 현장·혼용 표현 칩 (중립색 — 검색어·보조 정보) */
.p-field { display: flex; flex-wrap: wrap; gap: 6px; }
.p-fieldchip {
  font-family: var(--kr); font-size: 0.84rem; font-weight: 600;
  color: var(--text-1); background: var(--hover);
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px;
}

/* ═══ 봉제 현장 용어 — 표(현장어 → 표준어) ══════════════════ */
.field-view {
  position: absolute; inset: 0; z-index: 1;
  overflow-y: auto;
  padding: 22px max(24px, calc((100% - 1160px) / 2)) 12px;
  animation: grid-in .3s var(--ease);
}
.field-title {
  font-family: var(--kr); font-size: 1.04rem; font-weight: 800; color: var(--text-1);
  letter-spacing: -0.01em; margin-bottom: 8px; display: flex; align-items: baseline; gap: 10px;
}
.field-title span { font-family: var(--mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.04em; color: var(--text-3); }
.field-table { width: 100%; border-collapse: collapse; }
.field-table thead th {
  position: sticky; top: -22px; z-index: 2; background: var(--bg);
  text-align: left; font-family: var(--sans); font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-3);
  padding: 6px 14px; border-bottom: 1px solid var(--line-2);
}
.field-table td { padding: 5px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.field-table tbody tr:hover td { background: var(--hover); }
/* 메인: 표준 영단어(검정, 굵게) + STANDARD 배지 */
.ft-en-c { white-space: nowrap; }
.ft-en-main { font-family: var(--sans); font-size: 1.02rem; font-weight: 600; color: var(--text-1); letter-spacing: -0.01em; }
.ft-copy {
  margin-left: 8px; width: 22px; height: 22px; vertical-align: middle;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 5px; background: var(--input-bg); color: var(--text-3);
  cursor: pointer; opacity: 0; transition: background .14s, color .14s, border-color .14s, opacity .14s;
}
.field-table tr:hover .ft-copy { opacity: 1; }
.ft-copy:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* 설명 — 현장 표현(굵게) → 표준어(강조) · 설명문을 한 문장으로 정리 */
.ft-desc-t { font-family: var(--kr); font-size: 0.82rem; color: var(--text-2); line-height: 1.45; }
.ft-field-in { font-weight: 700; color: var(--text-1); }
.ft-alt { color: var(--text-3); margin-left: 6px; }
.ft-arrow { margin: 0 6px; color: var(--text-3); font-family: var(--mono); }
.ft-std-in { font-weight: 700; color: var(--text-1); }


/* ═══════════════════════════════════════════════════════════════
   2026-09 UI 개선 — 카테고리 탭(그리드 상단) · 선택/확대 · 반응형
   ═══════════════════════════════════════════════════════════════ */

/* ── 그리드 상단 툴바: 지식 메뉴 + 카테고리 탭 + 결과 수 ───────── */
.grid-toolbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  height: var(--toolbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 max(24px, calc((100% - 1440px) / 2));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.gt-menu { position: relative; flex-shrink: 0; display: flex; }
.grid-toolbar .cat-rail {
  flex: 1; min-width: 0; height: 100%;
  flex-direction: row; flex-wrap: nowrap;
  align-items: center; gap: 2px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.grid-toolbar .cat-rail::-webkit-scrollbar { display: none; }

/* 카테고리 탭 — 선택 상태가 분명한 하단 밑줄형 */
.grid-toolbar .cat-item {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 5px;
  padding: 0 10px; height: 100%;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: color .14s, border-color .14s;
}
.grid-toolbar .cat-item::before { display: none; }
.grid-toolbar .cat-item .ci-label {
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  letter-spacing: 0.01em; color: inherit;
}
.grid-toolbar .cat-item .ci-count {
  width: auto; font-family: var(--font-ui); font-size: 10.5px; font-weight: 500;
  color: var(--text-3); font-variant-numeric: tabular-nums;
}
.grid-toolbar .cat-item:hover { background: transparent; color: var(--text-1); }
.grid-toolbar .cat-item[aria-selected="true"] {
  color: var(--ivory); border-bottom-color: var(--ivory);
}
.grid-toolbar .cat-item[aria-selected="true"] .ci-label { font-weight: 600; }
.grid-toolbar .cat-item[aria-selected="true"] .ci-count { color: var(--text-2); font-weight: 600; }
.grid-toolbar .cat-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.gt-right { flex-shrink: 0; display: flex; align-items: center; gap: 10px; margin-left: auto; }
.gt-count {
  font-family: var(--font-ui); font-size: 11px; font-weight: 400;
  color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.gt-reset {
  padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 999px;
  background: transparent; color: var(--text-2); cursor: pointer;
  font-family: var(--font-ui); font-size: 10.5px; font-weight: 500; letter-spacing: 0.02em;
  transition: color .14s, border-color .14s, background .14s;
}
.gt-reset:hover { color: var(--ivory); border-color: var(--line-strong); background: var(--hover); }
.gt-reset[hidden] { display: none; }

/* ── Stitch 하위 분류: 상위 탭(밑줄형) 아래 한 단계 낮은 알약형 칩 ── */
.main-area { --subbar-h: 48px; }
.sub-rail {
  position: absolute; top: var(--toolbar-h); left: 0; right: 0; z-index: 29;
  height: var(--subbar-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 max(24px, calc((100% - 1440px) / 2));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  animation: sub-in .18s var(--ease);
}
.sub-rail::-webkit-scrollbar { display: none; }
.sub-rail[hidden] { display: none !important; }
@keyframes sub-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.sub-item {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: transparent; color: var(--text-2); cursor: pointer;
  font-family: var(--font-ui); font-size: 11.5px; font-weight: 500; letter-spacing: 0.01em;
  transition: color .15s, background .15s, border-color .15s;
}
.sub-item .si-count {
  font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums;
  transition: color .15s;
}
.sub-item:hover { color: var(--ivory); border-color: var(--line-strong); background: var(--hover); }
.sub-item[aria-selected="true"] {
  background: var(--ivory); border-color: var(--ivory); color: var(--bg); font-weight: 600;
}
.sub-item[aria-selected="true"] .si-count { color: var(--bg); opacity: 0.7; }
.sub-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 하위 줄이 펼쳐지면 그리드를 그만큼 내린다 */
.main-area.has-sub .cat-grid { top: calc(var(--toolbar-h) + var(--subbar-h)); }

@media (max-width: 900px) {
  .main-area { --subbar-h: 52px; }
  .sub-item { height: 36px; padding: 0 14px; }   /* 터치 대상 확보 */
}
@media (prefers-reduced-motion: reduce) {
  .sub-rail { animation: none; }
}

/* 3D 뷰·다른 모드에서는 툴바를 그대로 두되 그리드만 위치 보정 */
.main-area.field-mode .cat-grid,
.main-area.guide-mode .cat-grid { top: var(--toolbar-h); }
.stage { top: var(--toolbar-h); }

/* ── 상세 패널: 미선택 안내 ─────────────────────────────────── */

.hp-empty { margin: 0; padding: 0; max-width: 30ch; font-family: var(--font-ui); }
.hp-empty-title {
  margin: 0 0 6px;
  font-size: 15px; font-weight: 500; letter-spacing: -0.01em; color: var(--ivory);
}
.hp-empty-sub {
  margin: 0;
  font-size: 12.5px; font-weight: 400; line-height: 1.55; letter-spacing: 0.01em; color: var(--text-2);
}
.hover-panel.hp-live .hp-empty { display: none; }
/* 미선택 상태에서는 항목 자체를 감춘다 (임의 용어 노출 금지) */
.hover-panel:not(.hp-live) .hp-block,
.hover-panel:not(.hp-live) .hp-video { display: none !important; }

/* ── 카드 선택 상태 + 확대 버튼 ──────────────────────────────── */
.cat-grid .s-card { position: relative; }
.cat-grid .s-card .s-photo { transition: box-shadow .16s, border-color .16s; }
.cat-grid .s-card:hover .s-photo { box-shadow: 0 0 0 1px var(--line-strong); }
.cat-grid .s-card.is-selected .s-photo {
  box-shadow: 0 0 0 2px var(--ivory);
  border-color: var(--ivory);
}
.cat-grid .s-card.is-selected .s-en { color: var(--ivory); font-weight: 600; }
/* 선택 표시는 사진 테두리 + 제목 굵기로만 한다 (체크 아이콘 없음) */

.s-zoom {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 1px solid rgba(255,255,255,0.22); border-radius: 6px;
  background: rgba(10,11,14,0.58); color: #fff; cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: opacity .14s, background .14s, border-color .14s;
}
.s-card:hover .s-zoom,
.s-card:focus-within .s-zoom { opacity: 1; pointer-events: auto; }
.s-zoom:hover { background: rgba(10,11,14,0.86); border-color: rgba(255,255,255,0.5); }
.s-zoom:focus-visible { opacity: 1; pointer-events: auto; outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 이미지 확대 모달 ────────────────────────────────────────── */
.zoom-backdrop {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  background: rgba(6,7,10,0.88);
  animation: zoom-fade .18s ease;
}
.zoom-backdrop[hidden] { display: none; }
:root[data-theme="light"] .zoom-backdrop { background: rgba(20,22,40,0.7); }
@keyframes zoom-fade { from { opacity: 0 } to { opacity: 1 } }
.zoom-box {
  display: flex; flex-direction: column; gap: 14px;
  width: fit-content; max-width: min(1100px, 100%); max-height: 100%;
}
.zoom-head { display: flex; align-items: flex-start; gap: 16px; }
.zoom-headtext { min-width: 0; }
.zoom-cat {
  display: block; font-family: var(--font-ui); font-size: 8px; font-weight: 500;
  line-height: 1; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-3);
  margin-bottom: 7px;
}
.zoom-title {
  margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 400;
  letter-spacing: -0.02em; color: var(--ivory); word-break: keep-all;
}
.zoom-close {
  flex-shrink: 0; margin-left: auto;
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: color .14s, border-color .14s, background .14s;
}
.zoom-close:hover { color: var(--ivory); border-color: var(--line-strong); background: var(--hover); }
.zoom-stage { min-height: 0; display: flex; align-items: center; justify-content: center; }
/* 원본 비율 유지 — 늘리거나 자르지 않는다 */
.zoom-stage img {
  max-width: 100%; max-height: calc(100vh - 160px);
  width: auto; height: auto; object-fit: contain; display: block;
  border-radius: 4px;
}

/* ── 결과 없음 안내 ─────────────────────────────────────────── */
.empty-msg {
  position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%);
  text-align: center; z-index: 2;
}
.empty-msg .em-title {
  margin: 0 0 8px; font-family: var(--font-ui); font-size: 14px; font-weight: 500; color: var(--text-1);
}
.empty-msg .em-sub {
  margin: 0 0 18px; font-family: var(--font-ui); font-size: 12px; font-weight: 400; color: var(--text-3);
}
.empty-msg .em-reset {
  padding: 9px 18px; border: 1px solid var(--line-2); border-radius: 999px;
  background: transparent; color: var(--text-1); cursor: pointer;
  font-family: var(--font-ui); font-size: 11.5px; font-weight: 500;
  transition: color .14s, border-color .14s, background .14s;
}
.empty-msg .em-reset:hover { color: var(--ivory); border-color: var(--line-strong); background: var(--hover); }

/* ── 좁은 화면: 상세 패널을 오버레이로 ───────────────────────── */
.detail-toggle {
  position: fixed; z-index: 3100; left: 16px; bottom: 16px;
  display: none; align-items: center; gap: 7px;
  padding: 10px 15px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); color: var(--text-1); cursor: pointer;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  box-shadow: 0 8px 24px -10px rgba(0,0,0,0.6);
}
.detail-toggle[hidden] { display: none; }
.sidebar-scrim {
  position: fixed; inset: var(--header-h) 0 0; z-index: 2900;
  background: rgba(6,7,10,0.6);
}
.sidebar-scrim[hidden] { display: none; }

/* 열 수 전환 — 4 → 3 → 2 → 1 (이미지 비율은 aspect-ratio 로 보존) */
@media (max-width: 1280px) {
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 330px; }
}
@media (max-width: 900px) {
  .app-shell { flex-direction: row; }
  .detail-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; z-index: 3000;
    top: var(--header-h); bottom: 0; left: 0;
    width: min(340px, 86vw); max-height: none;
    border-right: 1px solid var(--line); border-bottom: 0;
    padding: 24px;
    transform: translateX(-102%);
    transition: transform .24s var(--ease);
  }
  .app-shell.detail-open .sidebar { transform: none; }
  .main-area { flex: 1; min-width: 0; }
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .cat-grid { grid-template-columns: minmax(0, 1fr); gap: 28px 0; padding: 20px 16px 24px; }
  .grid-toolbar { padding: 0 16px; gap: 8px; }
  .zoom-backdrop { padding: 20px; }
}

/* ═══════════════════════════════════════════════════════════════
   Stitch 전용 실제 봉제 영상 — 패널 버튼 + 중앙 모달
   (기존 2D 애니메이션·인라인 플레이어를 대체)
   ═══════════════════════════════════════════════════════════════ */
.hp-video { margin: 0; }
.hp-video[hidden] { display: none !important; }
.hp-video-btn {
  width: 100%; min-height: 44px;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; text-align: left; cursor: pointer;
  border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: transparent; color: var(--text-1);
  transition: color .16s, border-color .16s;
}
.hp-video-btn:hover { color: var(--ivory); border-color: var(--line-strong); }
.hp-video-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hp-video-icon {
  flex-shrink: 0; width: 18px; height: 18px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 50%;
  color: var(--ivory); font-size: 7px; line-height: 1; padding-left: 1px;
}
.hp-video-label {
  min-width: 0; font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  letter-spacing: -0.01em;
}

/* ── 영상 모달 ─────────────────────────────────────────────── */
.vm-backdrop {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  background: rgba(6,7,10,0.9);
  animation: zoom-fade .18s ease;
}
.vm-backdrop[hidden] { display: none; }
:root[data-theme="light"] .vm-backdrop { background: rgba(20,22,40,0.74); }
.vm-modal {
  width: min(960px, 100%);
  display: flex; flex-direction: column; gap: 14px;
  max-height: 100%;
}
.vm-head { display: flex; align-items: flex-start; gap: 16px; }
.vm-headtext { min-width: 0; }
.vm-kicker {
  display: block; font-family: var(--font-ui); font-size: 8px; font-weight: 500;
  line-height: 1; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 7px;
}
.vm-title {
  margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 400;
  letter-spacing: -0.02em; color: var(--ivory); word-break: keep-all;
}
.vm-close {
  flex-shrink: 0; margin-left: auto;
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: color .14s, border-color .14s, background .14s;
}
.vm-close:hover { color: var(--ivory); border-color: var(--line-strong); background: var(--hover); }
/* 16:9 반응형 플레이어 */
.vm-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000; border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
}
.vm-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.vm-fallback {
  margin: 0; font-family: var(--font-ui); font-size: 11.5px; font-weight: 400;
  color: var(--dont-color);
}
.vm-fallback[hidden] { display: none; }
.vm-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.vm-source {
  font-family: var(--font-ui); font-size: 11px; font-weight: 400; color: var(--text-3);
}
.vm-link {
  margin-left: auto;
  font-family: var(--font-ui); font-size: 11.5px; font-weight: 500;
  color: var(--text-1); text-decoration: underline; text-underline-offset: 3px;
  transition: color .14s;
}
.vm-link:hover { color: var(--ivory); }

@media (max-width: 560px) {
  .vm-backdrop { padding: 18px; }
  .vm-title { font-size: 17px; }
}

/* ── 용어집 배경의 커서 반응형 점: 카드가 주인공이므로 농도를 낮춘다 ── */
.dot-field.on { opacity: 0.45; }


/* ── 좌측 패널 맨 아래: 선택 가이드 (상황 · 이유) ─────────────── */
.hp-block[hidden] { display: none !important; }
.hp-guide { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hpg-row {
  display: flex; flex-direction: column; gap: 3px;
  padding-left: 10px; border-left: 2px solid var(--line-2);
}
.hpg-sit {
  font-family: var(--font-kr); font-size: 13px; font-weight: 500;
  letter-spacing: -0.01em; color: var(--text-1); word-break: keep-all;
}
.hpg-why {
  font-family: var(--font-kr); font-size: 12px; font-weight: 400; line-height: 1.55;
  letter-spacing: -0.01em; color: var(--text-2); word-break: keep-all;
}

/* 지식 유형이 하나뿐이면 메뉴 버튼을 감춘다 (display:flex 가 hidden 을 덮어쓰지 않게) */
.menu-btn[hidden] { display: none !important; }
