/* ============================================================
   COZZSET · 나를 소개해요 (its-me) 프로필 카드
   다크 퍼플/핑크/오렌지 · 글래스모피즘 · Noto Sans KR
   ============================================================ */

:root {
  --bg-deep: #110022;
  --ink: #f1eaff;
  --ink-soft: #cdb9ee;
  --ink-dim: #8a76aa;
  --pink: #f47fff;
  --orange: #ff9c6e;
  --line: rgba(196, 150, 255, 0.18);
  --line-strong: rgba(196, 150, 255, 0.4);
  --glass: rgba(20, 8, 30, 0.72);
  --card-font: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: linear-gradient(160deg, #110022 0%, #2a0a2e 45%, #3a0022 75%, #1a0510 100%);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 56px;
}

.im-loading, .im-error {
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: .04em;
  text-align: center;
  line-height: 1.8;
}
.im-error strong { color: #ff8a8a; display: block; font-size: 17px; margin-bottom: 6px; }
.im-error a {
  display: inline-block; margin-top: 16px; color: var(--pink);
  text-decoration: none; border: 1px solid var(--line-strong);
  padding: 8px 18px; border-radius: 10px; font-size: 13px;
}
.im-error a:hover { background: rgba(244,127,255,.12); }

/* ============================================================
   카드 (내보내기 대상)
   ============================================================ */
.im-stage {
  width: 100%;
  max-width: 940px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 비슷한 친구 — 카드 양옆 빈 공간(넓은 데스크톱에서만). body에 직접 붙어서 뷰포트
   기준으로 위치 잡음 — 카드 너비(940px)가 걸릴 일 없는 화면에서만 보이게 최소폭을 넉넉히 잡음. */
.im-friends-rail {
  display: none;
  position: fixed;
  top: 130px;
  width: 172px;
  flex-direction: column;
  gap: 10px;
  z-index: 1;
}
.im-friends-rail-left { left: 32px; }
.im-friends-rail-right { right: 32px; }
.im-friends-rail-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 2px;
}
.im-friend-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.im-friend-card:hover { background: rgba(244,127,255,.08); border-color: var(--line-strong); transform: translateY(-1px); }
.im-friend-card-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--line-strong);
  background: #1a0828;
}
.im-friend-card-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 1500px) {
  .im-friends-rail { display: flex; }
}

.im-card {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  font-family: var(--card-font);
  isolation: isolate;
}

/* 서류/명함 느낌의 이중 테두리 프레임 + 모서리 포인트 */
.im-frame {
  position: absolute;
  inset: 10px;
  z-index: 3;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.im-frame::before,
.im-frame::after,
.im-frame .corner {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  background: rgba(255, 255, 255, 0.55);
}
.im-frame::before { top: -1.5px; left: -1.5px; }
.im-frame::after { top: -1.5px; right: -1.5px; }
.im-frame .corner { bottom: -1.5px; left: -1.5px; }

/* 배경 레이어 (그라데이션/패턴/이미지) */
.im-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* 그라데이션 프리셋 */
.im-bg[data-grad="purple"]  { background: linear-gradient(160deg, #2a0a4e 0%, #4a1160 45%, #7d1a6a 100%); }
.im-bg[data-grad="sunset"]  { background: linear-gradient(160deg, #2a0a2e 0%, #7d1128 55%, #d44a27 100%); }
.im-bg[data-grad="ocean"]   { background: linear-gradient(160deg, #06172e 0%, #123a6a 50%, #1b7a8c 100%); }
.im-bg[data-grad="forest"]  { background: linear-gradient(160deg, #0a1f14 0%, #16432a 50%, #3f7d3a 100%); }
.im-bg[data-grad="rose"]    { background: linear-gradient(160deg, #2a0a2e 0%, #6a1445 50%, #d44a7a 100%); }
.im-bg[data-grad="midnight"]{ background: linear-gradient(160deg, #05060f 0%, #14163a 55%, #2a2f6a 100%); }
.im-bg[data-grad="ember"]   { background: linear-gradient(160deg, #1a0510 0%, #4a1210 45%, #b5451a 100%); }
.im-bg[data-grad="aurora"]  { background: linear-gradient(160deg, #0a1f2e 0%, #164a5a 40%, #6a2f8c 75%, #b53a9a 100%); }

/* 무늬(패턴) — 어두운 베이스 위에 반복 무늬
   무늬 색은 --pattern-color 로 지정(없으면 프리셋 기본색 폴백),
   베이스 색은 --pattern-base 로 지정(없으면 프리셋 기본 배경 폴백).
   script.js가 유저 지정색이 있으면 이 두 커스텀 프로퍼티를 인라인으로 덮어씀. */
.im-bg[data-pattern] { background-color: var(--pattern-base, #1a0828); }
.im-bg[data-pattern="dots"] {
  background-image: radial-gradient(var(--pattern-color, rgba(244,127,255,.22)) 1.5px, transparent 1.6px);
  background-size: 18px 18px;
  background-color: var(--pattern-base, #1c0a2e);
}
.im-bg[data-pattern="grid"] {
  background-image:
    linear-gradient(var(--pattern-color, rgba(255,180,110,.12)) 1px, transparent 1px),
    linear-gradient(90deg, var(--pattern-color, rgba(255,180,110,.12)) 1px, transparent 1px);
  background-size: 22px 22px;
  background-color: var(--pattern-base, #180a26);
}
.im-bg[data-pattern="diagonal"] {
  background-image: repeating-linear-gradient(45deg, var(--pattern-color, rgba(244,127,255,.10)) 0 2px, transparent 2px 14px);
  background-color: var(--pattern-base, #1d0a30);
}
.im-bg[data-pattern="hex"] {
  background-image:
    radial-gradient(circle at 50% 0, var(--pattern-color, rgba(255,156,110,.14)) 0 8px, transparent 9px),
    radial-gradient(circle at 0 50%, var(--pattern-color, rgba(244,127,255,.10)) 0 8px, transparent 9px);
  background-size: 30px 30px;
  background-color: var(--pattern-base, #190a28);
}
.im-bg[data-pattern="wave"] {
  background-image: repeating-radial-gradient(circle at 50% 120%, var(--pattern-color, rgba(244,127,255,.10)) 0 12px, transparent 12px 26px);
  background-color: var(--pattern-base, #1b0a2c);
}

/* 커스텀 이미지 배경 */
.im-bg[data-image] {
  background-size: cover;
  background-position: center;
}
/* 이미지/밝은 배경 위 텍스트 가독성용 어두운 오버레이 */
.im-bg-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(10,4,16,.35) 0%, rgba(10,4,16,.62) 100%);
  pointer-events: none;
}

/* 이펙트 캔버스 */
.im-fx {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* 실제 내용 — 트친소 시트 그리드 (가로로 긴 landscape 레이아웃)
   좌측(사진+추가정보) : 우측(퀵팩트) = 30% : 1fr 비율 유지,
   자기소개(bio)는 우측 컬럼 아래에 배치해서 좌측 사진 옆 세로 공간을 채워
   전체 카드를 넓고 낮게(가로 > 세로) 만든다. */
.im-inner {
  position: relative;
  z-index: 3;
  padding: 24px 28px 22px;
  color: #f6efff;
  display: grid;
  grid-template-columns: 30% 1fr;
  grid-template-areas:
    "left right"
    "left bio";
  grid-template-rows: auto 1fr;
  gap: 16px 24px;
  align-items: start;
}

/* ===== 좌측 컬럼: 사진 + 소속뱃지 박스 ===== */
.im-left { grid-area: left; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
/* 참가한 서버 / 추가정보 두 박스를 감싸는 컬럼 — 모바일(.im-left가 row로 바뀔 때)에도
   두 박스가 사진 옆에서 알아서 세로로 쌓이게 하기 위한 래퍼 */
.im-boxes { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 0; }

.im-photo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.im-photo-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.im-lv-tag {
  position: absolute;
  bottom: 6px;
  right: 6px;
  z-index: 2;
  font-size: 11px;
  font-weight: 800;
  color: #1a0510;
  /* 프로필 포인트색(그라데이션 2색) — script.js가 #im-card에 --accent-1/2로 지정 */
  background: linear-gradient(90deg, var(--accent-1, var(--pink)), var(--accent-2, var(--orange)));
  padding: 2px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.im-box {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 10px;
  flex: 1;
  min-height: 88px;
}
.im-box-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  color: rgba(255,255,255,.55);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.im-badge-stack { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.im-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  line-height: 1.5;
  white-space: nowrap;
}
.im-badge-lv {
  color: var(--accent-1, #ffd166);
  background: rgba(255,255,255,.08);
  border: 1px solid var(--accent-1, #ffd166);
}
/* 서버 태그(참가한 서버) — 공용 레지스트리의 그라데이션 색은 script.js가 인라인 background-image로 지정 */
.im-badge-servertag {
  color: #fff;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,.35);
  text-shadow: 0 1px 3px rgba(0,0,0,.55);
}
.im-badge-trust {
  color: #fff;
  border: 1.5px solid currentColor;
  /* color-mix() 제거: html2canvas가 계산된 color() 문법을 파싱 못 해 내보내기가 실패했음.
     반투명 배경은 인라인 rgba로 script.js에서 trust_color 기준 지정한다. */
  background: rgba(255, 255, 255, 0.12);
}
.im-badge-trust .tl-text { color: #fff; }
.im-badge-species {
  color: #ffe2cf;
  background: rgba(255,156,110,.16);
  border: 1px solid rgba(255,156,110,.4);
}
/* 커스텀 태그 — 색상은 script.js가 유저 지정 hex 기준 인라인 지정(color/background/borderColor) */
.im-badge-custom {
  color: #f47fff;
  background: rgba(244,127,255,.16);
  border: 1px solid rgba(244,127,255,.4);
}
.im-badge-empty { font-size: 11px; color: rgba(255,255,255,.4); }

/* ===== 우측 컬럼: 타이틀 + 퀵팩트 시트 ===== */
.im-right {
  grid-area: right;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 14px 16px;
  min-width: 0;
}
.im-sheet-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .01em;
  margin: 0 0 4px;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.im-name {
  font-size: 13.5px;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(255,255,255,.3);
}

/* 퀵팩트 라벨-값 줄 */
.im-qf-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dotted rgba(255,255,255,.18);
  font-size: 12.5px;
  flex-wrap: wrap;
}
.im-qf-row:last-child { border-bottom: none; }
.im-qf-label {
  flex: 0 0 92px;
  font-weight: 700;
  color: rgba(255,255,255,.55);
  letter-spacing: .02em;
}
.im-qf-value {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.im-qf-underline {
  border-bottom: 1px solid rgba(255,255,255,.4);
  padding: 0 2px 2px;
  min-width: 40px;
  color: #f6efff;
  font-weight: 700;
}
.im-qf-empty { color: rgba(255,255,255,.35); font-style: italic; }

/* 토글 칩 (선택되면 박스 강조) — 참고이미지의 [남][여] 토글 스타일 */
.im-toggle-row { display: flex; gap: 6px; flex-wrap: wrap; }
.im-toggle {
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.25);
  color: rgba(255,255,255,.5);
}
.im-toggle.on {
  border-color: #fff;
  color: #fff;
  font-weight: 800;
  background: rgba(255,255,255,.14);
}

/* 성향/선호장르 게이지 (퀵팩트 줄 안에 배치) — 실제 그래픽 프로그레스 바 */
.im-qf-bars { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 200px; }
.im-bar-row { display: flex; align-items: center; gap: 10px; font-size: 11.5px; }
.im-bar-label {
  width: 78px; flex-shrink: 0;
  color: rgba(255,255,255,.7); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 트랙 (배경) + 채워지는 바 */
.im-gauge {
  position: relative;
  flex: 1;
  height: 9px;
  min-width: 90px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.im-gauge-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-1, #f47fff) 0%, var(--accent-2, #ff9c6e) 100%);
  box-shadow: 0 0 10px var(--accent-glow, rgba(244, 127, 255, 0.5));
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
/* 5칸 눈금(구분선) — 5단계 게이지 느낌 */
.im-gauge-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
}
.im-gauge-ticks > i {
  flex: 1;
  border-right: 1px solid rgba(10, 4, 16, 0.35);
}
.im-gauge-ticks > i:last-child { border-right: none; }
.im-gauge-num {
  flex-shrink: 0;
  width: 30px;
  text-align: right;
  font-size: 11px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.8);
  font-variant-numeric: tabular-nums;
}

/* ===== 하단: 자기소개 박스 (전체 폭) ===== */
.im-bio-box {
  grid-area: bio;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 76px;
}
.im-bio {
  font-size: 13.5px;
  line-height: 1.7;
  color: #f2ecff;
  white-space: pre-wrap;
  word-break: break-word;
}
.im-bio-empty { font-size: 12.5px; color: rgba(255,255,255,.35); font-style: italic; }

/* 링크 버튼 (bio 박스 하단에 붙임) */
.im-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.im-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: #1a0510;
  background: linear-gradient(90deg, var(--accent-1, var(--pink)), var(--accent-2, var(--orange)));
  transition: transform .15s ease, box-shadow .15s ease;
}
.im-link-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px var(--accent-glow, rgba(244,127,255,.3)); }

/* 가입일 (우측 하단 흐릿) */
.im-joined {
  text-align: right;
  font-size: 10.5px;
  color: rgba(255,255,255,.4);
  margin-top: 8px;
  letter-spacing: .02em;
}

/* ===== 설정(톱니) 버튼 — 카드 밖 우상단 ===== */
.im-gear {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(20, 8, 30, 0.55);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, background .18s ease;
}
.im-gear:hover { transform: rotate(45deg); background: rgba(244,127,255,.3); }
.im-gear svg { width: 20px; height: 20px; }

/* 태그 (친구ID 등 소소한 용도로 재사용) */
.im-tag {
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  color: #f2ecff;
}
.im-tag.accent {
  background: rgba(244,127,255,.16);
  border-color: rgba(244,127,255,.4);
  color: #ffd9ff;
}

/* 친구추가 ID (퀵팩트 줄 안에 인라인 배치) */
.im-friend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(88,101,242,.2);
  border: 1px solid rgba(88,101,242,.5);
  padding: 3px 10px;
  border-radius: 999px;
  color: #dfe2ff;
}
.im-friend svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ============================================================
   카드 밖 요소 (내보내기에서 제외)
   ============================================================ */
.im-actions { display: flex; gap: 10px; }
.im-export-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: rgba(244,127,255,.1);
  color: var(--pink);
  transition: background .15s ease, transform .15s ease;
  font-family: var(--card-font);
}
.im-export-btn:hover { background: rgba(244,127,255,.2); transform: translateY(-1px); }
.im-export-btn:disabled { opacity: .55; cursor: default; transform: none; }

.im-foot {
  text-align: center;
  padding: 22px 18px 8px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
}
.im-foot p { margin: 0 0 14px; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.im-join-btn {
  display: inline-block;
  padding: 13px 30px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  color: #1a0510;
  background: linear-gradient(90deg, var(--pink), var(--orange));
  transition: transform .15s ease, box-shadow .15s ease;
}
.im-join-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(244,127,255,.35); }

/* ============================================================
   설정 패널 (슬라이드 인)
   ============================================================ */
.im-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(6, 2, 12, 0.62);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
.im-panel-overlay.open { opacity: 1; visibility: visible; }

.im-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 901;
  width: min(480px, 100vw);
  height: 100%;
  background: linear-gradient(160deg, #180528 0%, #22072e 60%, #2a0820 100%);
  border-left: 1px solid var(--line-strong);
  box-shadow: -20px 0 60px rgba(0,0,0,.55);
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.22,1,.36,1);
  display: flex;
  flex-direction: column;
  font-family: var(--card-font);
}
.im-panel.open { transform: translateX(0); }

.im-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.im-panel-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  background: linear-gradient(90deg, var(--pink), var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.im-panel-close {
  background: none; border: none; color: var(--ink-soft);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.im-panel-close:hover { color: #fff; }

.im-panel-body {
  overflow-y: auto;
  padding: 20px 22px 40px;
  flex: 1;
}
.im-panel-body::-webkit-scrollbar { width: 8px; }
.im-panel-body::-webkit-scrollbar-thumb { background: rgba(244,127,255,.3); border-radius: 4px; }

.im-field { margin-bottom: 22px; }
.im-field > label,
.im-field > .im-flabel {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 9px;
  letter-spacing: .02em;
}
.im-hint {
  font-size: 11.5px;
  color: var(--ink-dim);
  margin: -4px 0 9px;
  line-height: 1.5;
}

.im-input, .im-textarea, .im-select {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  padding: 11px 13px;
  font-family: var(--card-font);
  transition: border-color .15s ease;
}
.im-input:focus, .im-textarea:focus, .im-select:focus {
  outline: none;
  border-color: var(--pink);
}
.im-textarea { resize: vertical; min-height: 88px; line-height: 1.6; }
.im-select { appearance: none; cursor: pointer; }
.im-select option { background: #1a0828; color: var(--ink); }

/* 스와치(그라데이션/패턴/이펙트) */
.im-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.im-swatch {
  width: 46px; height: 46px;
  border-radius: 12px;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: transform .12s ease;
  overflow: hidden;
}
.im-swatch:hover { transform: scale(1.06); }
.im-swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--pink); }
.im-swatch span {
  position: absolute; bottom: 2px; left: 0; right: 0;
  font-size: 8.5px; text-align: center; color: #fff;
  text-shadow: 0 1px 2px #000;
}

/* 커스텀 배경 색상 지정 (그라데이션 시작/끝 · 무늬 색) */
.im-bg-custom {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
}
.im-bg-custom.sel {
  border-style: solid;
  border-color: var(--pink);
  box-shadow: 0 0 0 1px var(--pink) inset;
}
.im-bg-custom-title {
  flex: 1 1 100%;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: .02em;
}
.im-bg-color {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: none;
  cursor: pointer;
}
.im-bg-color-sep { font-size: 12px; color: var(--ink-dim); }
.im-bg-preview {
  flex: 1;
  min-width: 60px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.im-bg-custom-btn {
  flex-shrink: 0;
  background: rgba(244,127,255,.1);
  border: 1px solid var(--line-strong);
  color: var(--pink);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  font-family: var(--card-font);
  white-space: nowrap;
}
.im-bg-custom-btn:hover { background: rgba(244,127,255,.2); }
.im-bg-custom-btn.sel {
  background: rgba(244,127,255,.28);
  color: #fff;
  border-color: var(--pink);
}

.im-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.im-chip {
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  transition: all .13s ease;
}
.im-chip:hover { border-color: var(--line-strong); }
.im-chip.sel {
  background: rgba(244,127,255,.2);
  border-color: var(--pink);
  color: #fff;
}

/* 라디오 그룹 (=chip과 동일 룩) */
.im-radio-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* 슬라이더 (성향) */
.im-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.im-slider-row .sl-label { width: 96px; flex-shrink: 0; font-size: 13px; color: var(--ink); }
.im-range { flex: 1; accent-color: var(--pink); cursor: pointer; }
.im-slider-row .sl-val {
  width: 22px; text-align: center; font-weight: 700; color: var(--pink); font-size: 14px;
}

/* 장르 편집 행 */
.im-genre-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.im-genre-row .im-select { flex: 1; }
.im-genre-row .im-range { flex: 1; }
.im-genre-row .gr-val { width: 20px; text-align: center; color: var(--pink); font-weight: 700; }
/* 종족 다중 선택 (태그) */
.im-species-add { display: flex; gap: 8px; align-items: center; }
.im-species-add .im-select { flex: 1; }
.im-species-add .im-mini-btn { flex-shrink: 0; white-space: nowrap; }
.im-species-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.im-species-list:empty { display: none; }
.im-species-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
  background: rgba(255,156,110,.16);
  border: 1px solid rgba(255,156,110,.45);
  color: #ffe2cf;
}
.im-species-tag-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.12);
  color: #ffe2cf;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font-family: var(--card-font);
}
.im-species-tag-x:hover { background: rgba(255,156,110,.5); color: #fff; }

/* 커스텀 태그 편집 (이름 입력 + 색상 피커 + 추가, 태그 리스트) */
.im-customtag-add { display: flex; gap: 8px; align-items: center; }
.im-customtag-add .im-input { flex: 1; min-width: 0; }
.im-customtag-add .im-mini-btn { flex-shrink: 0; white-space: nowrap; }
.im-customtag-color {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: none;
  cursor: pointer;
}
.im-customtag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.im-customtag-list:empty { display: none; }
.im-customtag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 8px 6px 10px;
  border-radius: 999px;
  /* color/background/border-color는 script.js가 유저 지정색 기준 인라인 지정 */
  background: rgba(244,127,255,.16);
  border: 1px solid rgba(244,127,255,.45);
  color: #f47fff;
}
.im-customtag-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,.35);
}
.im-customtag-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.14);
  color: currentColor;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font-family: var(--card-font);
}
.im-customtag-x:hover { background: rgba(255,255,255,.28); color: #fff; }

/* 참가한 서버 (서버 태그 — 공용 레지스트리, 그라데이션은 script.js가 인라인 지정) */
.im-servertag-attach { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.im-servertag-attach .im-select { flex: 1; }
.im-servertag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.im-servertag-list:empty { display: none; }
.im-servertag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 8px 6px 10px;
  border-radius: 999px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.35);
}
.im-servertag-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.28);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font-family: var(--card-font);
}
.im-servertag-x:hover { background: rgba(0,0,0,.5); }

.im-mini-btn {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--card-font);
}
.im-mini-btn:hover { border-color: var(--pink); color: #fff; }
.im-add-btn {
  margin-top: 4px;
  font-size: 13px;
  background: rgba(244,127,255,.1);
  border: 1px dashed var(--line-strong);
  color: var(--pink);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  width: 100%;
  font-family: var(--card-font);
}
.im-add-btn:hover { background: rgba(244,127,255,.18); }

/* 링크 버튼 편집 */
.im-linkedit-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.im-linkedit-row .im-input { flex: 1; }
.im-linkedit-row .im-input.lbl { flex: 0 0 34%; }

/* 디스코드 역할 동기화 강조 박스 */
.im-sync-box {
  border: 1px solid rgba(88,101,242,.45);
  background: rgba(88,101,242,.1);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 22px;
}
.im-sync-box .im-sync-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 900; color: #cdd3ff; margin-bottom: 4px;
}
.im-sync-box .im-sync-note {
  font-size: 11.5px; color: #a9b0e6; line-height: 1.55; margin-bottom: 16px;
}

/* 업로드 미리보기 */
.im-upload-preview {
  display: flex; align-items: center; gap: 12px; margin-top: 10px;
}
.im-upload-preview img {
  width: 56px; height: 56px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--line-strong); background: #1a0828;
}
.im-file-note { font-size: 11px; color: var(--ink-dim); margin-top: 6px; }

/* 저장 바 (패널 하단 고정) */
.im-panel-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: rgba(10,4,16,.5);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.im-save-status {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  color: var(--ink-soft);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}
.im-save-status.saving { color: #cdd3ff; border-color: rgba(88,101,242,.5); background: rgba(88,101,242,.1); }
.im-save-status.saved { color: #7effb0; border-color: rgba(126,255,176,.4); background: rgba(126,255,176,.08); }
.im-save-status.err { color: #ff9c9c; border-color: rgba(255,120,120,.45); background: rgba(255,120,120,.08); }

/* 토스트 */
.im-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  z-index: 1000;
  background: rgba(20, 8, 30, 0.95);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 13px 22px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: 0 12px 34px rgba(0,0,0,.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, transform .25s ease, visibility .25s ease;
  max-width: 90vw;
  text-align: center;
}
.im-toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.im-toast.err { border-color: #ff8a8a; color: #ffd9d9; }
.im-toast.ok { border-color: #8affc8; }

/* X 자랑하기 모달 */
.im-brag {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6,2,12,.7);
  padding: 20px;
}
.im-brag.open { display: flex; }
.im-brag-box {
  background: linear-gradient(160deg, #1e0730, #2a0820);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.im-brag-box .emoji { font-size: 42px; margin-bottom: 8px; }
.im-brag-box h3 {
  margin: 0 0 8px; font-size: 19px; font-weight: 900;
  background: linear-gradient(90deg, var(--pink), var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.im-brag-box p { margin: 0 0 22px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.7; }
.im-brag-x {
  display: inline-flex; align-items: center; gap: 8px;
  background: #000; color: #fff; text-decoration: none;
  font-weight: 700; font-size: 14px; padding: 12px 26px; border-radius: 12px;
  transition: transform .15s ease;
}
.im-brag-x:hover { transform: translateY(-1px); }
.im-brag-later {
  display: block; margin-top: 14px; background: none; border: none;
  color: var(--ink-dim); font-size: 12.5px; cursor: pointer; width: 100%;
  font-family: var(--card-font);
}
.im-brag-later:hover { color: var(--ink-soft); }

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 640px) {
  .im-stage { max-width: 460px; }
}

@media (max-width: 520px) {
  #app { padding: 20px 14px 44px; }
  .im-inner {
    padding: 16px 14px 14px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "right"
      "bio";
  }
  .im-left { flex-direction: row; }
  .im-photo-frame { width: 92px; height: 92px; aspect-ratio: unset; flex-shrink: 0; }
  .im-box { min-height: unset; }
  .im-sheet-title { font-size: 19px; }
  .im-qf-label { flex-basis: 76px; }
  .im-panel-body { padding: 18px 16px 40px; }
  .im-panel-head, .im-panel-foot { padding-left: 16px; padding-right: 16px; }
  .im-bar-label, .im-slider-row .sl-label { width: 80px; }
  .im-linkedit-row { flex-wrap: wrap; }
  .im-linkedit-row .im-input.lbl { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .im-panel, .im-panel-overlay, .im-gear, .im-toast { transition: none; }
}
