@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;700&family=Inter:wght@300;400;700&display=swap');

/* ===== 디자인 토큰 ===== */
:root {
  --font-sans: 'Noto Sans KR', 'Inter', Arial, sans-serif;

  /* 색상 */
  --bg:            #faf8f3;
  --bg-card:       #ffffff;
  --bg-warm:       #fff9ee;
  --primary:       #FFD966;
  --primary-dark:  #e6c000;
  --accent:        #87C5EA;
  --accent-dark:   #5aabe0;
  --text:          #2d2d2d;
  --text-dim:      #6b6b6b;
  --muted:         #a8a8a8;
  --link:          #5aabe0;
  --border:        rgba(0, 0, 0, 0.07);

  /* 그림자 */
  --shadow-xs: 0 1px 4px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.09);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-card-hover: 0 12px 32px rgba(135,197,234,0.30);

  /* 반경 */
  --radius-sm:   10px;
  --radius-md:   18px;
  --radius-lg:   24px;
  --radius-pill: 999px;

  /* 레이아웃 */
  --container-max-width: 1400px;
  --gap:         16px;
  --card-gap:    8px;
  --card-width:  108px;
  --card-height: 180px;
  --card-padding: 12px;

  /* 9-slice (옵션, ui-9slice 클래스 추가 시 활성화) */
  --btn-slice-image:    url('/images/ui/button-slice.png');
  --input-slice-image:  url('/images/ui/input-slice.png');
  --select-slice-image: url('/images/ui/select-slice.png');
}

/* ===== 리셋 & 기본 ===== */
* { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  min-height: 100%;
  scroll-behavior: smooth;
}

html, body {
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
  transition: color 0.15s;
}
a:hover { color: var(--accent-dark); }

h1, h2, h3 { margin: 0; padding: 0; }

/* ===== 파티클 캔버스 ===== */
#particle-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ===== 헤더 — 떠다니는 pill 네비바 ===== */
header {
  position: sticky;
  top: 12px;
  z-index: 100;
  margin: 12px 20px 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255,255,255,0.7) inset;
  padding: 10px 20px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
}

.header-logo { flex: 0 0 auto; }

.header-logo-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.logo-lala {
  color: #2d2d2d;
  background: var(--primary);
  border-radius: 6px;
  padding: 2px 6px;
  margin-right: 2px;
}
.logo-info {
  color: var(--accent-dark);
}

nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
}

nav a {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}
nav a:hover {
  background: rgba(135, 197, 234, 0.15);
  color: var(--text);
}
nav a.active {
  background: var(--primary);
  color: #2d2d2d;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

/* ===== SPA 콘텐츠 마운트 포인트 ===== */
#app {
  flex: 1 0 auto;
  position: relative;
  z-index: 1;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#app.page-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 공통 컨테이너 ===== */
.container {
  width: min(100%, clamp(450px, 80vw, var(--container-max-width)));
  padding: 28px 24px;
  margin: 0 auto;
  min-width: 0;
}

/* ===== 버튼 ===== */
button {
  height: 36px;
  box-sizing: border-box;
  padding: 0 16px;
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  margin: 3px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.18s ease,
              border-color 0.15s;
}
button:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent);
}
button:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
}

.btn-pill {
  height: 36px;
  box-sizing: border-box;
  padding: 0 16px;
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  margin: 3px;
  line-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.18s ease,
              border-color 0.15s;
}
.btn-pill:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent);
  color: var(--text);
}

.btn-coffee {
  font-size: 12px;
  padding: 0 12px;
  height: 34px;
  color: var(--text-dim);
  border-color: var(--border);
  text-decoration: none;
}
.btn-coffee:hover { color: var(--text); }

/* API 키 관련 버튼 */
#submitApiKeys,
.btn-submit {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
  font-weight: 600;
  height: 40px;
  padding: 0 24px;
  font-size: 14px;
}
#submitApiKeys:hover,
.btn-submit:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--bg-warm);
  color: var(--text);
  border-color: var(--accent);
}

/* API 키 +/- 버튼 */
.add-api-key,
.remove-api-key {
  width: 30px;
  height: 30px;
  padding: 0;
  margin: 0 2px;
  font-size: 18px;
}

/* 9-slice 옵션 (body.ui-9slice 클래스 추가 시 활성화) */
body.ui-9slice button,
body.ui-9slice .btn-pill {
  border: 8px solid transparent;
  border-image: var(--btn-slice-image) 8 fill stretch;
  border-image-outset: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}
body.ui-9slice button:hover,
body.ui-9slice .btn-pill:hover { filter: brightness(1.05); transform: none; }

body.ui-9slice .add-api-key,
body.ui-9slice .remove-api-key {
  border-width: 6px;
}

/* ===== 입력 / 셀렉트 ===== */
input[type="text"],
input[type="number"],
.api-key-input {
  height: 36px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(135,197,234,0.18);
}
input::placeholder { color: var(--muted); }

select {
  height: 36px;
  padding: 0 32px 0 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6b6b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  outline: none;
  transition: border-color 0.15s;
}
select:focus { border-color: var(--accent); }
select option {
  background: var(--bg-card);
  color: var(--text);
}

/* 9-slice 입력/셀렉트 */
body.ui-9slice input[type="text"],
body.ui-9slice input[type="number"],
body.ui-9slice .api-key-input {
  border: 8px solid transparent;
  border-image: var(--input-slice-image) 8 fill stretch;
  border-image-outset: 0;
  background: transparent;
  border-radius: 0;
  color: var(--text);
  box-shadow: none;
}
body.ui-9slice input::placeholder { color: rgba(0,0,0,0.4); }

body.ui-9slice select {
  border: 8px solid transparent;
  border-image: var(--select-slice-image) 8 fill stretch;
  border-image-outset: 0;
  background: transparent;
  border-radius: 0;
  color: var(--text);
  box-shadow: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232d2d2d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}
body.ui-9slice select option { background: var(--bg-card); color: var(--text); }

/* ===== 푸터 ===== */
footer {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  background: rgba(255,255,255,0.70);
  backdrop-filter: blur(10px);
  color: var(--text-dim);
  text-align: center;
  padding: 16px 10px;
  font-size: 11px;
  line-height: 1.6;
  border-top: 1px solid var(--border);
}
footer p { margin: 2px 0; }
footer a { color: var(--link); }
footer a:hover { color: var(--accent-dark); }

/* ===== 홈 페이지 ===== */
.page-home {
  width: min(100%, clamp(450px, 88vw, var(--container-max-width)));
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* 히어로 */
.hero {
  display: flex;
  align-items: center;
  gap: 48px;
  padding: 60px 0 48px;
}

.hero-text {
  flex: 1 1 0;
  min-width: 0;
}

.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.hero-title {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 16px;
}

.hero-title-accent {
  color: var(--accent-dark);
}

.hero-desc {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-dim);
  margin: 0 0 28px;
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 14px 32px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.18s ease;
}
.btn-cta:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: var(--shadow-card-hover);
  color: #fff;
}

.hero-image {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-image img {
  height: clamp(200px, 28vw, 340px);
  width: auto;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(135,197,234,0.25));
}

/* 기능 소개 */
.features {
  padding: 0 0 32px;
}

.features-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.visit-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  font-size: 13px;
  flex-wrap: wrap;
}
.visit-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}
.visit-stat-icon { font-size: 14px; line-height: 1; }
.visit-stat-val  { font-weight: 700; color: var(--text); }
.visit-stat-label { color: var(--text-dim); }
.visit-sep { color: var(--border); font-size: 16px; line-height: 1; }

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.feature-card {
  display: block;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px 18px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.22s ease;
}
.feature-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-card-hover);
}

.feature-icon {
  font-size: 24px;
  margin-bottom: 10px;
}

.feature-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.feature-card p {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0;
}

/* ===== 계정조회 페이지 ===== */
.page-account {
  width: min(100%, clamp(450px, 80vw, var(--container-max-width)));
  margin: 0 auto;
  padding: 28px 24px;
}

.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}
.page-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

/* API 키 카드 */
.api-key-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.api-key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.api-key-row .api-key-input {
  flex: 1 1 0;
  min-width: 0;
}

.api-key-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.loading-msg {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.error-msg {
  margin-top: 12px;
  font-size: 13px;
  color: #e53935;
  background: #fff5f5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

/* 캐릭터 목록 툴바 */
.char-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
}

.char-title {
  font-size: 18px;
  font-weight: 700;
  margin-right: 4px;
}
.char-title #character-count {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 4px;
}

.char-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.toolbar-sep {
  color: var(--border);
  user-select: none;
  margin: 0 4px;
}

/* ===== 캐릭터 애니메이션 오버레이 ===== */
.character-card.anim-active {
  overflow: visible;
  z-index: 5;
}

/* anim-active 시 원본 캐릭터 이미지 래퍼를 숨겨 인접 카드 가림 방지 */
.character-card.anim-active .character-image-wrapper {
  visibility: hidden;
}

.char-anim-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: rgba(10, 8, 6, 0.5);
  cursor: default;
}

/* .character-card img { max-width:100%; height:auto } specificity=(0,1,1) 보다 높게 유지 */
.char-anim-overlay .char-anim-img {
  position: absolute;
  left: 50%;
  top: 33%;
  width: 300px;
  height: 300px;
  max-width: none;
  margin: 0;
  transform: translate(-50%, -50%);
  object-fit: contain;
  pointer-events: none;
}

.char-anim-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.55);
  gap: 4px;
}

.char-anim-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.char-anim-code {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
}

.char-anim-close {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 11;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
  box-shadow: none;
  line-height: 1;
}
.char-anim-close:hover {
  background: rgba(0, 0, 0, 0.85);
  transform: none;
}

.char-anim-controls {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.char-anim-select {
  height: 28px;
  font-size: 11px;
  padding: 0 22px 0 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  width: 100%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b6b6b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
[data-theme="dark"] .char-anim-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239b9890'/%3E%3C/svg%3E");
}

.char-anim-speed {
  display: flex;
  align-items: center;
  gap: 4px;
}
.char-anim-speed-label {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.char-anim-speed-range {
  flex: 1;
  min-width: 0;
  accent-color: var(--primary);
  cursor: pointer;
  height: 4px;
}
.char-anim-speed-val {
  font-size: 10px;
  color: var(--text-dim);
  min-width: 34px;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}
.char-anim-speed-reset {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  font-size: 12px;
  border-radius: 50%;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
  box-shadow: none;
  line-height: 1;
}
.char-anim-speed-reset:hover { background: rgba(0,0,0,0.06); transform: none; }

.char-anim-export {
  position: relative;
  display: flex;
  width: 100%;
}
.char-anim-export-main {
  flex: 1;
  height: 28px;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary);
  border: 1px solid var(--primary-dark, #e6c200);
  border-right: none;
  color: #1a1a1a;
  border-radius: var(--radius-pill) 0 0 var(--radius-pill);
  cursor: pointer;
  padding: 0 10px;
  margin: 0;
}
.char-anim-export-main:hover:not(:disabled) { filter: brightness(1.1); transform: none; box-shadow: none; border-color: var(--primary-dark, #e6c200); }
.char-anim-export-main:disabled { opacity: 0.6; cursor: default; }
.char-anim-export-toggle {
  width: 22px;
  height: 28px;
  font-size: 10px;
  font-weight: 700;
  background: var(--primary);
  border: 1px solid var(--primary-dark, #e6c200);
  border-left: 1px solid rgba(0,0,0,0.18);
  color: #1a1a1a;
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  cursor: pointer;
  padding: 0;
  margin: 0;
  line-height: 1;
}
.char-anim-export-toggle:hover:not(:disabled) { filter: brightness(1.1); transform: none; box-shadow: none; }
.char-anim-export-toggle:disabled { opacity: 0.6; cursor: default; }
.char-anim-export-menu {
  position: absolute;
  bottom: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 30;
  list-style: none;
  padding: 4px 0;
  margin: 0;
}
.char-anim-export-menu li { margin: 0; padding: 0; }
.char-anim-export-menu button {
  display: block;
  width: 100%;
  height: 26px;
  font-size: 11px;
  background: none;
  border: none;
  border-radius: 0;
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
  color: var(--text);
  margin: 0;
  box-shadow: none;
}
.char-anim-export-menu button:hover { background: rgba(255,255,255,0.08); transform: none; }

/* 애니메이션 컨트롤 접기/펴기 토글 */
.char-anim-controls-toggle {
  display: none; /* 팝업 카드에서는 숨김 */
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 3px 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
  margin: 0 0 2px;
  box-shadow: none;
}
.char-anim-controls-toggle:hover { background: rgba(0,0,0,0.04); transform: none; box-shadow: none; }
.char-anim-ctrl-arrow { font-size: 9px; }
.char-anim-controls-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.char-anim-controls-body[hidden] { display: none; }
/* 슬롯 내에서는 토글 표시 */
#char-anim-controls-slot .char-anim-controls-toggle { display: flex; }

/* ===== 캐릭터 상세 탭 애니메이션 호스트 ===== */
.char-detail-anim-host .char-anim-overlay {
  background: transparent;
}
.char-detail-anim-host .char-anim-close {
  display: none;
}
.char-detail-anim-host .char-anim-bar {
  background: rgba(0, 0, 0, 0.45);
  bottom: 4px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: auto;
  min-width: 100px;
  border-radius: 6px;
  padding: 2px 8px;
}
.char-detail-anim-host > img#char-detail-img {
  display: none;
}
.char-detail-anim-host .char-anim-img {
  top: 33%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
}

/* 애니메이션 컨트롤 슬롯 (캐릭터 조회 탭 전용) */
.char-anim-controls-slot:not(:empty) {
  margin: 12px 0 0;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
#char-anim-controls-slot .char-anim-controls {
  position: static;
  transform: none;
  box-shadow: none;
  border: none;
  background: transparent;
  padding: 0;
  min-width: 0;
  width: 100%;
}

/* ===== 카드 그리드 ===== */
#character-display-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--card-width));
  gap: var(--card-gap);
  align-items: start;
  justify-content: start;
  width: 100%;
}

/* ===== 캐릭터 카드 ===== */
.character-card {
  background-color: var(--bg-card);
  background-image: var(--panel-bg-image, none);
  background-size: cover;
  background-position: center top;
  padding: var(--card-padding);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  text-align: center;
  overflow: hidden;
  width: var(--card-width);
  height: var(--card-height);
  margin: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.22s ease;
}
.character-card:hover {
  transform: translateY(-6px) scale(1.04);
  box-shadow: var(--shadow-card-hover);
}
.character-card img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  margin: 0 auto 8px auto;
}

.character-image-wrapper {
  position: absolute;
  left: 50%;
  top: 33%;
  width: 300px;
  height: 300px;
  transform: translate(-50%, -50%);
  overflow: visible;
  z-index: 0;
}
.character-image-wrapper img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.character-world-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
}
.character-world-icon img { display: block; }

.character-info {
  position: relative;
  z-index: 1;
  height: 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  overflow: hidden;
  text-align: left;
  padding: 0;
}

.character-info-row {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.character-info p,
.character-meta span {
  font-size: 12px;
  line-height: 1.2;
  margin: 0;
}

.character-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  min-width: 0;
  width: 100%;
  min-height: 1.2em;
}

.character-class {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.character-level {
  flex: 0 0 auto;
  white-space: nowrap;
  color: #e53935;
}

.character-card .character-info p {
  white-space: nowrap;
  overflow: hidden;
}

.character-name { font-weight: 700; }


/* ===== 옵션 패널 (필터/표시설정/TMI) ===== */
.options-panel {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 14px 20px;
  margin-bottom: 20px;
}

.options-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 0;
  margin-bottom: 0;
}

.options-tab {
  background: transparent;
  border: 1.5px solid transparent;
  cursor: pointer;
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--font-sans);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  margin: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.options-tab:hover {
  background: rgba(135,197,234,0.12);
  color: var(--text);
  transform: none;
  box-shadow: none;
}
.options-tab.active {
  background: var(--primary);
  color: var(--text);
  border-color: var(--primary-dark);
  font-weight: 700;
}
.options-tab-sep {
  color: var(--border);
  user-select: none;
  margin: 0 2px;
}

.options-tab-panels { margin-top: 0; }

.options-tab-panel {
  display: none;
  padding: 12px 0 4px;
}
.options-tab-panel.is-open { display: block; }

/* 필터 */
#filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.filter-category {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
}
.filter-category h3 {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-option {
  flex: 0 0 calc(12.5% - 8px);
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.filter-option label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 5px;
  max-width: 100%;
  font-size: 13px;
}

.account-filter, .class-filter, .world-filter { flex: 0 0 auto; }

/* 표시 설정 */
#display-settings-options > div {
  padding: 4px 0;
  font-size: 13px;
}
#display-settings-options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* TMI */
#tmis {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.tmi-category {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
}
.tmi-category h3 {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.world-union-level-element {
  display: flex;
  justify-content: space-between;
  padding: 0;
  margin: 0;
}
.union-world { flex-grow: 1; padding: 0; margin: 0; font-size: 13px; }
.union-level { text-align: right; min-width: 50px; padding: 0; margin: 0; font-size: 13px; font-weight: 600; }

/* 캐릭터 목록 섹션 여백 */
#character-container { margin-bottom: 16px; }
#character-container > .char-toolbar { padding-bottom: 12px; }

/* ApexCharts 레이블 */
.apexcharts-datalabels text,
.apexcharts-datalabels tspan {
  fill: #fff !important;
  stroke: rgba(0,0,0,0.55);
  stroke-width: 2px;
  paint-order: stroke fill;
}

/* ===== 커피 QR 모달 ===== */
.coffee-qr-overlay {
  display: none;
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.coffee-qr-overlay.is-open { display: flex !important; }

.coffee-qr-box {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  padding: 28px;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  width: 100%;
}
.coffee-qr-box, .coffee-qr-box * { color: var(--text) !important; }

.coffee-qr-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
}
.coffee-qr-desktop img { display: block; margin: 0 auto 12px; border-radius: var(--radius-sm); }
.coffee-qr-mobile { display: none; margin-bottom: 12px; }
.coffee-qr-golink {
  display: inline-block;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  color: var(--text) !important;
  background: #fee500;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.coffee-qr-golink:hover { background: #fada0a; }
.coffee-qr-text { margin: 0 0 16px; font-size: 13px; color: var(--text-dim) !important; }
.coffee-qr-close {
  padding: 8px 20px;
  cursor: pointer;
  font-size: 13px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--bg-warm);
  color: var(--text) !important;
  box-shadow: var(--shadow-xs);
}
.coffee-qr-close:hover { background: var(--bg-card); }

/* ===== 반응형 ===== */
@media (max-width: 768px) {
  .hero {
    flex-direction: column;
    padding: 36px 0 32px;
    gap: 28px;
    text-align: center;
  }
  .hero-image { order: -1; }
  .hero-image img { height: 180px; }
  .btn-cta { align-self: center; }
}

/* 햄버거 메뉴 버튼: 모바일에서만 표시 */
#mobile-nav-btn { display: none; }

/* ===== 모바일 패널 백드롭 ===== */
.mobile-panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 299;
}
.mobile-panel-backdrop.open { display: block; }

@media (max-width: 720px) {
  /* 헤더 2행 레이아웃 */
  header {
    position: sticky;
    top: 6px;
    margin: 6px 10px 0;
    border-radius: var(--radius-lg);
    padding: 8px 12px 6px;
    flex-wrap: wrap;
    gap: 0;
    align-items: center;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.96);
  }
  [data-theme="dark"] header {
    background: rgba(26, 25, 32, 0.97);
  }
  #mobile-nav-btn {
    display: flex;
    flex-shrink: 0;
    order: 1;
    margin: 0;
  }
  .header-logo {
    order: 2;
    flex: 1;
    text-align: center;
  }
  .header-actions {
    order: 3;
    margin-left: 0;
    gap: 4px;
    flex-shrink: 0;
  }
  .header-actions .btn-pill { margin: 0; }
  /* 검색창 — 2행으로 */
  form.header-search {
    order: 10;
    flex: 0 0 100%;
    width: 100%;
    margin-top: 5px;
    box-sizing: border-box;
  }
  #header-search-input {
    width: 100%;
    flex: 1;
  }
  /* 좌측 슬라이드 내비 패널 */
  nav {
    position: fixed;
    top: 0; left: 0; bottom: 0; right: auto;
    width: min(75vw, 280px);
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 60px 16px 16px;
    z-index: 300;
    display: flex;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
    box-shadow: var(--shadow-lg);
  }
  [data-theme="dark"] nav { background: rgba(35,31,26,0.97); }
  nav.mobile-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s ease;
  }
  nav a { padding: 10px 14px; font-size: 15px; width: 100%; text-align: left; }
  #bgm-toggle-btn { display: none; }
}

@media (max-width: 600px) {
  .filter-option { flex: 0 0 calc(25% - 8px); }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 다크 모드 ===== */
[data-theme="dark"] {
  --bg:        #1a1a1f;
  --bg-card:   #252530;
  --bg-warm:   #1f1e2a;
  --text:      #e8e6df;
  --text-dim:  #9b9890;
  --muted:     #5a5856;
  --border:    rgba(255,255,255,0.08);
  --shadow-xs: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-card-hover: 0 12px 32px rgba(87,197,234,0.15);
}
[data-theme="dark"] header {
  background: rgba(26, 25, 32, 0.90);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.07) inset;
}
[data-theme="dark"] footer {
  background: rgba(20, 20, 26, 0.88);
  border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .error-msg {
  background: rgba(229,57,53,0.14);
  color: #ff8a87;
}
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239b9890' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}
[data-theme="dark"] nav a:hover {
  background: rgba(135,197,234,0.12);
}
[data-theme="dark"] .char-anim-overlay {
  background: rgba(0,0,0,0.6);
}
[data-theme="dark"] .loading-msg { color: var(--text-dim); }

/* ===== 토글 스위치 ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--muted);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  gap: 8px;
}
.settings-row-label { font-size: 13px; color: var(--text); flex: 1; line-height: 1.3; }
.settings-row-sub { font-size: 11px; color: var(--text-dim); }
.settings-panel-header { background: var(--bg-warm); }

/* ===== 배경 전환 버튼 ===== */
.bg-nav {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.bg-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.75);
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: background 0.15s;
  transform: none;
}
.bg-nav-btn:hover { background: rgba(255,255,255,0.95); transform: none; box-shadow: 0 1px 4px rgba(0,0,0,0.25); }

/* ===== 관리자 UI ===== */
.admin-icon-btn {
  padding: 0 8px;
  min-width: 32px;
  height: 32px;
  font-size: 15px;
  line-height: 30px;
  text-align: center;
}
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.admin-modal {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  width: min(320px, 90vw);
  box-shadow: var(--shadow-lg);
  position: relative;
}
.admin-modal-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}
.admin-pw-input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.admin-pw-input:focus { border-color: var(--accent); }
.admin-modal-close {
  position: absolute;
  top: 10px; right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-dim);
  padding: 0;
  line-height: 1;
  box-shadow: none;
  transform: none;
}
.admin-modal-close:hover { background: none; transform: none; box-shadow: none; }
.admin-panel {
  position: fixed;
  top: 70px; right: 16px;
  width: min(320px, 92vw);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  overflow: hidden;
  animation: adminPanelIn 0.2s ease;
  max-height: calc(100vh - 90px);
  display: flex;
  flex-direction: column;
}
.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--primary);
  font-weight: 700;
  font-size: 13px;
  color: #333;
  flex-shrink: 0;
}
.admin-panel-header .admin-modal-close { position: static; }

/* 탭 바 */
.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.admin-tab-btn {
  flex: 1;
  padding: 7px 4px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  box-shadow: none;
  transform: none;
  letter-spacing: 0.02em;
}
.admin-tab-btn:hover { color: var(--text); background: none; transform: none; box-shadow: none; }
.admin-tab-btn.active { color: var(--text); border-bottom-color: var(--primary); }

/* 탭 본문 */
.admin-panel-body { padding: 10px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.admin-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

/* 서브 섹션 구분선 라벨 */
.admin-sub-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* 아이템 목록 */
.admin-bg-list {
  max-height: 94px;
  overflow-y: auto;
  margin-bottom: 6px;
}
.admin-bg-item {
  background: var(--bg);
  border-radius: 5px;
  padding: 3px 6px;
  margin-bottom: 3px;
}
.admin-bg-item-main {
  display: flex;
  align-items: center;
  gap: 3px;
}
/* 마스크 편집 행 (토글) */
.admin-bg-item-mask {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px 0 2px;
}
.admin-bg-item-mask.open { display: flex; }
.admin-bg-item-mask-label {
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.admin-mask-input {
  flex: 1;
  font-size: 10px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  min-width: 0;
}
.admin-mask-input:focus { border-color: var(--accent); }
.admin-mask-ok {
  background: none; border: none;
  font-size: 13px; color: var(--accent, #5aabe0);
  cursor: pointer; padding: 0 2px; flex-shrink: 0;
  box-shadow: none; transform: none;
}
.admin-mask-ok:hover { background: none; transform: none; box-shadow: none; }

/* 공통 URL/텍스트 표시 */
.admin-bg-url {
  flex: 1;
  font-size: 10px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 마스크 토글 버튼 */
.admin-bg-mask-btn {
  background: none; border: none;
  font-size: 10px; font-weight: 700;
  color: var(--muted); cursor: pointer;
  padding: 0 3px; flex-shrink: 0;
  box-shadow: none; transform: none;
  border-radius: 3px;
}
.admin-bg-mask-btn.has-mask { color: var(--accent, #5aabe0); }
.admin-bg-mask-btn:hover { color: var(--text); background: none; transform: none; box-shadow: none; }

/* 삭제 버튼 */
.admin-bg-remove {
  background: none; border: none;
  font-size: 11px; cursor: pointer;
  color: var(--muted); padding: 0 2px;
  flex-shrink: 0; box-shadow: none; transform: none;
}
.admin-bg-remove:hover { color: var(--text); background: none; transform: none; box-shadow: none; }

/* 빈 상태 노트 */
.admin-empty-note {
  font-size: 10px; color: var(--muted);
  margin: 4px 0; padding: 2px 0;
}

/* 추가 폼 */
.admin-add-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-add-form input {
  width: 100%;
  padding: 5px 8px;
  font-size: 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  outline: none;
}
.admin-add-form input:focus { border-color: var(--accent); }
.admin-btn-pair {
  display: flex;
  gap: 4px;
}
.admin-btn-pair button {
  flex: 1;
  font-size: 11px;
  padding: 5px 0;
}
.admin-save-btn { background: var(--accent-dark, #5aabe0) !important; }

/* BGM 입력 행 */
.admin-bgm-inputs {
  display: flex;
  gap: 4px;
}
.admin-bgm-inputs input:first-child { width: 72px; flex-shrink: 0; }
.admin-bgm-inputs input:last-child  { flex: 1; min-width: 0; }

/* 푸터 */
.admin-panel-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* 메시지 행 */
.admin-msg-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.admin-msg-row:last-child { border-bottom: none; }
.admin-msg-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text);
}

/* ===== 헤더 검색 ===== */
.header-search {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 4px 0 12px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.header-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(135,197,234,0.18);
}
#header-search-input {
  height: 28px;
  width: 140px;
  border: none;
  background: transparent;
  padding: 0;
  font-size: 12px;
  color: var(--text);
  outline: none;
  box-shadow: none;
}
#header-search-input::placeholder { color: var(--muted); }
.header-search-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.header-search-btn:hover {
  transform: none;
  box-shadow: none;
  background: rgba(135,197,234,0.18);
  border-radius: 50%;
  color: var(--text);
}
.header-search-btn:active { transform: none; }

/* ===== 캐릭터 상세 조회 페이지 ===== */
.page-character {
  width: min(100%, clamp(450px, 80vw, var(--container-max-width)));
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* 상단: 이미지 + 기본정보 */
/* ── 캐릭터 조회 새 레이아웃 ─────────────────────── */
.char-search-outer {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 16px 24px;
  margin-bottom: 16px;
}

.char-main-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.char-overview-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px;
}

#char-detail-tabs-section {
  flex: 1;
  min-width: 0;
}

.char-overview-power {
  background: var(--primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 14px 0 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: #333;
}
.char-overview-label { font-size: 11px; }
.char-overview-power-val { font-size: 14px; }

.char-overview-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 900px) {
  .char-main-layout { flex-direction: column; align-items: stretch; }
  .char-overview-panel { width: 100%; }
}

/* 능력치 탭 전투력 배너 */
.char-stat-power-hero {
  background: linear-gradient(135deg, rgba(255,217,102,0.18) 0%, var(--bg-card) 100%);
  border: 1px solid rgba(230,192,0,0.45);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.char-stat-power-hero-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.char-stat-power-hero-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
}

/* 능력치 티어 배색 */
.char-stat-tier-group { margin-bottom: 12px; }
.char-stat-tier-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  padding: 4px 0 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.char-stat-tier-label-0 { color: #c8a000; }
.char-stat-tier-label-1 { color: #3a9e48; }
.char-stat-tier-label-2 { color: #3a78c0; }
.char-stat-tier-label-3 { color: #c06000; }

.char-stat-item.stat-tier-0 { background: rgba(255,200,0,0.15);  border-left: 3px solid #e6c000; }
.char-stat-item.stat-tier-1 { background: rgba(68,190,84,0.12);  border-left: 3px solid #44be54; }
.char-stat-item.stat-tier-2 { background: rgba(65,150,230,0.12); border-left: 3px solid #4196e6; }
.char-stat-item.stat-tier-3 { background: rgba(230,120,0,0.12);  border-left: 3px solid #e67800; }

/* 공유 툴팁 */
.char-tooltip {
  z-index: 9000;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 11px;
  max-width: 260px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  line-height: 1.6;
}
.tip-header { font-weight: 700; margin-bottom: 2px; color: var(--text-dim); font-size: 10px; }
.tip-line { color: var(--text); }
.tip-sub { color: var(--text-dim); padding-left: 8px; }
.tip-grade-leg { color: #44be54; }
.tip-grade-uni { color: #e6c000; }
.tip-grade-epi { color: #a046d2; }
.tip-grade-rar { color: #4169e1; }

/* (구) 레이아웃 — 하위호환 유지 */
.char-detail-top {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
}

.char-detail-image-col {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.char-detail-img-wrap {
  width: 120px;
  height: 200px;
  background: var(--bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

#char-detail-img {
  position: absolute;
  left: 50%;
  top: 33%;
  width: 300px;
  height: 300px;
  transform: translate(-50%, -50%);
  object-fit: contain;
}

.char-detail-info-col {
  flex: 1 1 0;
  min-width: 0;
}

.char-detail-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 14px;
}

/* 캐릭터 이름 아래 전투력 */
.char-detail-power {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 3px 0 10px;
}
.char-detail-power-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}
.char-detail-power-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.char-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.char-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 13px;
}

.char-meta-label {
  color: var(--text-dim);
  font-size: 11px;
}

/* API 키 / 이름 검색 프롬프트 */
.char-key-desc {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.char-key-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.char-key-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.char-key-row input { flex: 1; max-width: 280px; }

.char-name-search > p {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text-dim);
}
.char-name-search form {
  display: flex;
  gap: 8px;
}
.char-name-search input { flex: 1; max-width: 280px; }

/* 탭 섹션 */
#char-detail-tabs-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.char-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  width: 100%;
  box-sizing: border-box;
}
.char-tabs::-webkit-scrollbar { display: none; }

.char-tab {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-dim);
  box-shadow: none;
  margin: 0 0 -1px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.char-tab:hover {
  background: var(--bg);
  color: var(--text);
  transform: none;
  box-shadow: none;
}
.char-tab.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent-dark);
  font-weight: 700;
  background: transparent;
}
.char-tab:active { transform: none; box-shadow: none; }

.char-tab-content {
  padding: 20px;
  min-height: 200px;
}

/* 스탯 그리드 */
.char-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 5px;
}
.char-stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
}
.char-stat-name { color: var(--text-dim); }
.char-stat-val { font-weight: 600; }
.char-stat-ap {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-dim);
}

/* 장비 그리드 */
.char-equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.char-equip-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px;
  border: 1px solid var(--border);
}
.char-equip-item.g-leg { border-color: rgba(68,190,84,0.5);  background: rgba(68,190,84,0.06); }
.char-equip-item.g-uni { border-color: rgba(230,168,0,0.5);  background: rgba(230,168,0,0.06); }
.char-equip-item.g-epi { border-color: rgba(160,70,210,0.5); background: rgba(160,70,210,0.06); }
.char-equip-item.g-rar { border-color: rgba(65,105,225,0.5); background: rgba(65,105,225,0.06); }
.equip-icon { width: 32px; height: 32px; image-rendering: pixelated; flex: 0 0 auto; }
.equip-info { min-width: 0; flex: 1; }
.equip-slot { font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.equip-name { font-size: 12px; word-break: keep-all; line-height: 1.4; }
.equip-stars { font-size: 11px; color: #c88a00; margin-top: 2px; }
.equip-grade { font-size: 11px; margin-top: 1px; }
.equip-grade.g-leg { color: #30a040; }
.equip-grade.g-uni { color: #c88a00; }
.equip-grade.g-epi { color: #9030c0; }
.equip-grade.g-rar { color: #3460c8; }

/* 스킬 */
.char-skill-grade-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.char-skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.char-skill-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}
.skill-icon { width: 32px; height: 32px; image-rendering: pixelated; flex: 0 0 auto; }
.skill-info { min-width: 0; }
.skill-name { font-size: 12px; word-break: keep-all; line-height: 1.4; }
.skill-level { font-size: 11px; color: var(--text-dim); }

/* 어빌리티 */
.char-ability-grade {
  display: inline-block;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.char-ability-grade.g-leg { border-color: rgba(68,190,84,0.6);  color: #30a040; }
.char-ability-grade.g-uni { border-color: rgba(230,168,0,0.6);  color: #c88a00; }
.char-ability-grade.g-epi { border-color: rgba(160,70,210,0.6); color: #9030c0; }
.char-ability-grade.g-rar { border-color: rgba(65,105,225,0.6); color: #3460c8; }
.char-ability-list { display: flex; flex-direction: column; gap: 6px; }
.char-ability-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
}

/* 유니온 */
.char-union-info { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.char-union-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.char-union-val {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-dark);
  line-height: 1;
}
.char-union-section { margin-bottom: 16px; }
.char-union-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.char-union-stat-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px;
}
.char-union-stat-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
}

/* 기타 */
.char-etc-section { margin-bottom: 24px; }
.char-etc-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.char-etc-val { font-size: 26px; font-weight: 700; color: var(--accent-dark); margin: 0; }

/* 공통 */
.char-tab-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
  margin: 0;
}

/* ===== 광장 등록 버튼 (계정조회 카드) ===== */
.plaza-register-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  z-index: 6;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1.4;
}
.character-card:hover .plaza-register-btn { opacity: 1; }
.plaza-register-btn.plaza-register-done {
  background: #5cba6a;
  opacity: 1;
  cursor: default;
}

/* ===== 카드 기능 패널 (계정조회 카드 클릭 시) ===== */
.char-card-menu {
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: var(--radius-md);
  background: rgba(10, 8, 6, 0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
}
.char-card-menu-btn {
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: center;
  line-height: 1;
  padding: 0 10px;
  transition: background 0.12s, color 0.12s;
}
.char-card-menu-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.char-card-menu-btn.menu-btn-done { background: #5cba6a; color: #fff; border-color: #5cba6a; cursor: default; }
.char-card-menu-close {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: none;
  padding: 0;
  z-index: 11;
  line-height: 1;
}
.char-card-menu-close:hover { background: rgba(0,0,0,0.85); transform: none; }
.char-menu-page { display: flex; flex-direction: column; width: 100%; gap: 5px; }
.char-menu-page-hidden { display: none !important; }

/* ===== wanderer 공통 (마이룸·광장) ===== */
.wanderer-header { margin-bottom: 16px; }
.wanderer-header h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.wanderer-canvas-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(160deg, #1a1814 0%, #232018 60%, #1c1e24 100%);
  box-shadow: var(--shadow-md);
}
.wanderer-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  cursor: pointer;
}

/* 팝업 */
.wanderer-popup {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px 14px;
  min-width: 160px;
  text-align: center;
  animation: fadeInUp 0.15s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.wanderer-popup-close {
  position: absolute;
  top: 6px; right: 8px;
  background: none; border: none;
  font-size: 14px; color: var(--muted);
  cursor: pointer; padding: 0; line-height: 1;
}
.popup-world-icon { width: 20px; height: 20px; object-fit: contain; margin-bottom: 4px; }
.wanderer-popup-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.wanderer-popup-sub  { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
.wanderer-popup-world { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.wanderer-popup-msg {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  margin: 4px 0 6px;
}
.wanderer-popup-link {
  display: inline-block;
  font-size: 11px;
  color: var(--link);
  text-decoration: none;
  margin-top: 4px;
}
.wanderer-popup-link:hover { text-decoration: underline; }

/* ===== 마이룸 ===== */
.page-myroom {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}
.wanderer-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.wanderer-canvas-col { flex: 1; min-width: 0; }
.wanderer-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.myroom-key-desc { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.myroom-key-row  { display: flex; gap: 6px; }
.myroom-key-row input { flex: 1; min-width: 0; }
.myroom-search {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.myroom-search input { flex: 1; min-width: 0; }
.myroom-list-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.myroom-char-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
}
.myroom-char-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}
.myroom-char-thumb-wrap {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  background: var(--border);
}
.myroom-char-thumb-img {
  position: absolute;
  width: 150px;
  height: 150px;
  left: 50%;
  top: 33%;
  transform: translate(-50%, -50%);
}
.myroom-char-no-img { background: var(--border); border-radius: 6px; }
.myroom-char-meta { flex: 1; min-width: 0; }
.myroom-char-name { display: block; font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.myroom-char-sub  { display: block; font-size: 10px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.myroom-char-speech-preview {
  display: block;
  font-size: 10px;
  color: var(--primary-dark, #b8860b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.myroom-char-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  width: 42px;
}
.myroom-speech-edit-btn,
.myroom-remove-btn {
  width: 100%;
  font-size: 10px;
  padding: 2px 0;
  text-align: center;
  flex-shrink: 0;
}

/* 대사 인라인 편집기 */
.myroom-speech-edit {
  width: 100%;
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.myroom-speech-input {
  width: 100%;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}
.myroom-speech-edit-btns {
  display: flex;
  gap: 6px;
}
.myroom-speech-edit-btns .btn-submit,
.myroom-speech-edit-btns .btn-ghost {
  flex: 1;
  font-size: 11px;
  padding: 4px 0;
}

/* ===== 광장 ===== */
.page-plaza {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}
.plaza-canvas-row { margin-bottom: 12px; }
.plaza-canvas-wrap { position: relative; }
.plaza-canvas { height: 500px; }
.plaza-count-badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: 4px;
}
.plaza-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.plaza-count-label {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}
#plaza-count-input { width: 72px; text-align: center; }
.plaza-rep-info { font-size: 13px; color: var(--text); margin-bottom: 2px; }
.plaza-rep-name { font-weight: 700; }
.plaza-rep-level { color: var(--text-dim); font-size: 11px; }
.plaza-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 10px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  line-height: 1.35;
  width: 100%;
}
.plaza-consent-row input[type="checkbox"] { margin-top: 1px; flex-shrink: 0; }

.plaza-msg-input {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--bg-card);
  color: var(--text);
}

.info-msg {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  padding: 12px;
}

/* ===== 말풍선 토글 버튼 ===== */
.canvas-speech-btn {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 5;
  background: rgba(0,0,0,0.45);
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 14px;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.canvas-speech-btn:hover { background: rgba(0,0,0,0.65); }
.canvas-speech-btn.speech-off { opacity: 0.4; }

/* ===== BGM 플레이어 ===== */
.bgm-btn {
  font-size: 14px;
  padding: 0 8px;
  height: 28px;
}
.bgm-btn.bgm-playing { background: var(--primary); color: #333; }
.bgm-panel {
  position: fixed;
  top: 60px; right: 16px;
  width: min(300px, 90vw);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  display: none;
  flex-direction: column;
  max-height: calc(100vh - 80px);
  overflow: hidden;
}
.bgm-panel.bgm-panel-open { display: flex; }
.bgm-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--primary);
  font-weight: 700;
  font-size: 13px;
  color: #333;
  flex-shrink: 0;
}
.bgm-panel-header .admin-modal-close { position: static; color: #555; }
.bgm-panel-body {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  min-height: 0;
}
.bgm-now-playing {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.bgm-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.bgm-progress-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  cursor: pointer;
  margin: 6px 0;
  position: relative;
}
.bgm-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  pointer-events: none;
  transition: width 0.3s linear;
}
.bgm-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin: 6px 0;
}
.bgm-ctrl-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  line-height: 1;
}
.bgm-ctrl-btn:hover { color: var(--primary); }
.bgm-mode-row {
  display: flex;
  gap: 6px;
  margin: 6px 0;
  flex-wrap: wrap;
}
.bgm-mode-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.bgm-mode-btn.bgm-mode-active { background: var(--primary); color: #333; border-color: var(--primary); font-weight: 700; }
.bgm-volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 11px;
  color: var(--text-dim);
}
.bgm-volume-row input[type="range"] { flex: 1; }
.bgm-section-toggle {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 8px;
  user-select: none;
}
.bgm-section-toggle:hover { color: var(--text); }
.bgm-track-list { margin-top: 4px; }
.bgm-track-item {
  padding: 4px 6px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bgm-track-item:hover { background: var(--bg); }
.bgm-track-item.bgm-track-active { background: var(--primary); color: #333; font-weight: 700; }
.bgm-playlist-list { margin-top: 4px; }
.bgm-playlist-item {
  padding: 4px 6px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bgm-playlist-item:hover { background: var(--bg); }
.bgm-playlist-item.bgm-pl-active { background: var(--accent-light, #e8f4fd); font-weight: 700; }
[data-theme="dark"] .bgm-playlist-item.bgm-pl-active { background: rgba(90,171,224,0.2); }
.bgm-custom-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.bgm-custom-row input {
  flex: 1;
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text);
}
.bgm-custom-row button { font-size: 11px; padding: 0 10px; }

/* 반응형 */
@media (max-width: 720px) {
  #header-search-input { width: 90px; }
  .wanderer-layout { flex-direction: column; }
  .wanderer-sidebar { width: 100%; }

  /* BGM 패널 — 우측 전체 슬라이드 */
  .bgm-panel {
    top: 0 !important; right: 0 !important; bottom: 0 !important;
    width: min(85vw, 320px) !important;
    height: 100dvh !important; max-height: 100dvh !important;
    border-radius: var(--radius-md) 0 0 var(--radius-md) !important;
    display: flex !important;
    visibility: hidden;
    transform: translateX(100%);
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }
  .bgm-panel.bgm-panel-open {
    visibility: visible;
    transform: translateX(0);
    transition: transform 0.25s ease;
  }

  /* 설정·관리자 패널 — 우측 전체 슬라이드 */
  .admin-panel {
    top: 0 !important; right: 0 !important; bottom: 0 !important;
    width: min(85vw, 320px) !important;
    height: 100dvh !important; max-height: 100dvh !important;
    border-radius: var(--radius-md) 0 0 var(--radius-md) !important;
    animation: mobileRightPanelIn 0.25s ease !important;
  }
}
@media (max-width: 580px) {
  .char-detail-top { flex-direction: column; align-items: center; }
  .char-detail-info-col { width: 100%; }
  .char-detail-name { font-size: 18px; }
}

/* ===== 어드민/설정 패널 슬라이드 인 ===== */
@keyframes adminPanelIn {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes mobileRightPanelIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* ===== 커피 플로팅 버튼 ===== */
.coffee-float-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
}
.coffee-float-main {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,217,102,0.92);
  border: 1.5px solid #e6c200;
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #2d2d2d;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, box-shadow 0.15s;
  white-space: nowrap;
}
.coffee-float-main:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.coffee-float-dismiss {
  position: absolute;
  top: -7px;
  right: -7px;
  background: rgba(60,60,60,0.75);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.coffee-float-dismiss:hover { background: rgba(0,0,0,0.9); }

/* ── 운세 탭 ─────────────────────────────────────── */
.fortune-wrap { padding: 4px 0; }

.fortune-header {
  background: linear-gradient(135deg, var(--bg-warm) 0%, var(--bg-card) 100%);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}
.fortune-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.fortune-date  { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.fortune-meta  { font-size: 12px; color: var(--text-dim); }
.fortune-zod   { color: var(--accent-dark); font-size: 11px; }

.fortune-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.fortune-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.fortune-badge-bday {
  background: rgba(255,210,0,0.18);
  border-color: var(--primary-dark);
  color: var(--text);
}

.fortune-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
@media (max-width: 900px) { .fortune-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .fortune-grid { grid-template-columns: 1fr 1fr; } }

@media (max-width: 480px) {
  .char-tabs { padding: 8px 6px 0; gap: 1px; }
  .char-tab  { padding: 0 8px; font-size: 12px; height: 30px; }
}

.fortune-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: fortuneCardIn 0.38s ease both;
}
.fortune-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.fortune-sc-5 { border-color: rgba(230,192,0,0.6);   background: rgba(255,215,0,0.07); }
.fortune-sc-4 { border-color: rgba(68,190,84,0.4);   background: rgba(68,190,84,0.05); }
.fortune-sc-2 { border-color: rgba(150,150,150,0.3); }
.fortune-sc-1 { border-color: rgba(200,60,60,0.4);   background: rgba(200,60,60,0.05); }

.fortune-card-header {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
}
.fortune-icon  { font-size: 14px; line-height: 1; }
.fortune-label { color: var(--text); }

.fortune-stars       { font-size: 13px; line-height: 1; letter-spacing: 1px; }
.fortune-star        { color: var(--muted); }
.fortune-star.on     { color: #e6c000; }

.fortune-card-text {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 2px;
}

.fortune-summary {
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px 16px;
}
.fortune-summary-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.fortune-summary-body {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 2.0;
  margin: 0;
}
.fortune-sum-good { color: #3a9e48; font-weight: 600; }
.fortune-sum-bad  { color: #c84040; font-weight: 600; }
[data-theme="dark"] .fortune-sum-good { color: #5ccf69; }
[data-theme="dark"] .fortune-sum-bad  { color: #e06060; }

/* 운세 로딩 */
.fortune-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  gap: 14px;
}
.fortune-loading-crystal {
  font-size: 44px;
  animation: fortuneCrystalPulse 1.6s ease-in-out infinite;
  display: block;
}
.fortune-loading-text {
  font-size: 13px;
  color: var(--text-dim);
  animation: fortuneTextBlink 1.6s ease-in-out infinite;
}
@keyframes fortuneCrystalPulse {
  0%, 100% { transform: scale(1);    opacity: 0.75; filter: none; }
  50%       { transform: scale(1.14); opacity: 1;    filter: drop-shadow(0 0 10px rgba(160,100,255,0.55)); }
}
@keyframes fortuneTextBlink {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1;   }
}

/* 라라 말풍선 인트로 */
.fortune-lara-intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  animation: fortuneFadeUp 0.45s ease both;
}
.fortune-lara-crystal { font-size: 26px; flex-shrink: 0; margin-top: 3px; line-height: 1; }
.fortune-lara-bubble {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  position: relative;
  flex: 1;
}
.fortune-lara-bubble::before {
  content: '';
  position: absolute;
  left: -8px; top: 12px;
  border: 8px solid transparent;
  border-right-color: var(--border);
}
.fortune-lara-bubble::after {
  content: '';
  position: absolute;
  left: -6px; top: 14px;
  border: 6px solid transparent;
  border-right-color: var(--bg-warm);
}
.fortune-lara-name { font-weight: 700; color: var(--primary-dark); }
.fortune-lara-grade { font-weight: 700; }
.fortune-grade-dalgil  { color: #e6c000; }
.fortune-grade-gil     { color: #44be54; }
.fortune-grade-jung    { color: var(--text-dim); }
.fortune-grade-hyung   { color: #f08030; }
.fortune-grade-daehyung{ color: #c83c3c; }

/* 등장 애니메이션 */
@keyframes fortuneCardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
@keyframes fortuneFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}
.fortune-header  { animation: fortuneFadeUp 0.4s ease both; }
.fortune-summary { animation: fortuneFadeUp 0.4s ease both; }

/* 호버 힌트 아이콘 */
.fortune-tip-hint {
  margin-left: auto;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.15s;
}
.fortune-card:hover .fortune-tip-hint { opacity: 0.55; }

/* 라라의 분석 플로팅 패널 */
.fortune-tip {
  position: fixed;
  z-index: 9900;
  width: 260px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 2px solid rgba(150, 100, 255, 0.55);
  border-radius: var(--radius-sm);
  padding: 10px 13px 11px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.22), 0 1px 4px rgba(0,0,0,0.12);
  pointer-events: none;
}
.fortune-tip-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.01em;
}
.fortune-tip-body {
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.65;
}

/* ── 네비게이션 드롭다운 ───────────────────────────────────────── */
.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}
.nav-dropdown-btn {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-dropdown-btn:hover {
  background: rgba(135, 197, 234, 0.15);
  color: var(--text);
}
.nav-dropdown-btn.active {
  background: var(--primary);
  color: #2d2d2d;
  font-weight: 700;
}
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 148px;
  z-index: 250;
  display: none;
  flex-direction: column;
  padding: 4px;
}
.nav-dropdown.open .nav-dropdown-menu { display: flex; }
.nav-dropdown-menu a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  display: block;
  font-size: 13px;
}
[data-theme="dark"] .nav-dropdown-menu {
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}
@media (max-width: 720px) {
  .nav-dropdown { width: 100%; flex-direction: column; align-items: flex-start; }
  .nav-dropdown-btn { padding: 10px 14px; font-size: 15px; width: 100%; text-align: left; }
  .nav-dropdown-menu {
    position: static;
    transform: none;
    box-shadow: none;
    border: none;
    border-left: 2px solid var(--border);
    border-radius: 0;
    padding: 0 0 4px 0;
    margin-left: 28px;
    min-width: unset;
    width: auto;
  }
  .nav-dropdown-menu a { font-size: 14px; }
}

/* ── Back to Work 페이지 ──────────────────────────────────────── */
.page-backtowork {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px;
}
.btw-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 20px;
}
.btw-controls {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.btw-search {
  display: flex;
  gap: 8px;
}
.btw-search input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}
.btw-canvas-wrap {
  flex: 1;
  display: flex;
  justify-content: flex-start;
}
#btw-canvas {
  max-width: 100%;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  display: block;
}
.btw-quick-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btw-flip-btn { font-size: 12px; padding: 3px 10px; }
.btw-flip-active { background: var(--primary) !important; color: #2d2d2d !important; }
.btw-overlay-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.btw-adjust {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.btw-adjust summary {
  padding: 7px 12px;
  cursor: pointer;
  color: var(--text-dim);
  user-select: none;
  list-style: none;
  font-size: 12px;
}
.btw-adjust summary::-webkit-details-marker { display: none; }
.btw-adjust summary::before { content: '▸ '; }
.btw-adjust[open] summary::before { content: '▾ '; }
.btw-adjust[open] summary { border-bottom: 1px solid var(--border); color: var(--text); }
.btw-adjust-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
  padding: 10px 12px 4px;
}
.btw-adjust-label { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.btw-stepper { display: flex; align-items: center; gap: 4px; }
.btw-step-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.btw-step-btn:hover { background: var(--bg-warm); }
.btw-step-val {
  width: 52px;
  text-align: center;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
}
.btw-step-unit { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.btw-step-val::-webkit-outer-spin-button,
.btw-step-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.btw-step-val[type=number] { -moz-appearance: textfield; }
.btw-adjust-footer { padding: 6px 12px 8px; display: flex; justify-content: flex-end; }
.btw-adjust-footer .btn-ghost { font-size: 11px; padding: 3px 10px; }
@media (max-width: 640px) {
  .btw-layout { flex-direction: column; }
  .btw-controls { flex: 0 0 auto; width: 100%; }
}
