/* ===== DESIGN TOKENS ===== */
:root {
  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;

  /* Fonts */
  --font-display: 'Noto Serif KR', Georgia, serif;
  --font-body: 'Noto Sans KR', 'Helvetica Neue', sans-serif;
}

/* ===== BRIGHT FANTASY PALETTE (Light) ===== */
:root, [data-theme="light"] {
  --color-bg:             #faf8f3;
  --color-surface:        #fff9f0;
  --color-surface-2:      #fef6ea;
  --color-surface-offset: #f3ede3;
  --color-surface-offset-2: #ece5d9;
  --color-divider:        #ddd5c6;
  --color-border:         #d1c9b8;

  --color-text:           #2c2618;
  --color-text-muted:     #7a7060;
  --color-text-faint:     #b5ab9a;
  --color-text-inverse:   #faf8f3;

  --color-primary:        #8b6914;
  --color-primary-hover:  #6d520f;
  --color-primary-active: #52400c;
  --color-primary-highlight: #f0e4c8;

  --color-demon:          #7b3fa0;
  --color-demon-light:    #f3e8fa;
  --color-human:          #2563a0;
  --color-human-light:    #e8f0fa;

  --shadow-sm: 0 1px 2px oklch(0.3 0.02 70 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.3 0.02 70 / 0.08);
  --shadow-lg: 0 12px 32px oklch(0.3 0.02 70 / 0.12);
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --color-bg:             #1a1814;
  --color-surface:        #201e19;
  --color-surface-2:      #262420;
  --color-surface-offset: #1e1c17;
  --color-surface-offset-2: #2a2722;
  --color-divider:        #302d27;
  --color-border:         #3d3a33;

  --color-text:           #d9d3c7;
  --color-text-muted:     #8a8272;
  --color-text-faint:     #5d5749;
  --color-text-inverse:   #1a1814;

  --color-primary:        #d4a94e;
  --color-primary-hover:  #b8902e;
  --color-primary-active: #9a781f;
  --color-primary-highlight: #3a3326;

  --color-demon:          #b57ade;
  --color-demon-light:    #2a2234;
  --color-human:          #5ea0e0;
  --color-human-light:    #1e2a3a;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:             #1a1814;
    --color-surface:        #201e19;
    --color-surface-2:      #262420;
    --color-surface-offset: #1e1c17;
    --color-surface-offset-2: #2a2722;
    --color-divider:        #302d27;
    --color-border:         #3d3a33;
    --color-text:           #d9d3c7;
    --color-text-muted:     #8a8272;
    --color-text-faint:     #5d5749;
    --color-text-inverse:   #1a1814;
    --color-primary:        #d4a94e;
    --color-primary-hover:  #b8902e;
    --color-primary-active: #9a781f;
    --color-primary-highlight: #3a3326;
    --color-demon:          #b57ade;
    --color-demon-light:    #2a2234;
    --color-human:          #5ea0e0;
    --color-human-light:    #1e2a3a;
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
    --shadow-md: 0 4px 12px oklch(0 0 0 / 0.3);
    --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.4);
  }
}

/* ===== GLOBAL STYLES ===== */
body {
  font-family: var(--font-body);
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover {
  color: var(--color-primary-hover);
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 248, 243, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(44, 38, 24, 0.08);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}
[data-theme="dark"] .header {
  background: rgba(26, 24, 20, 0.92);
  border-bottom: 1px solid rgba(217, 211, 199, 0.08);
}

.header-inner {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

.logo svg {
  width: 28px;
  height: 28px;
}

.nav-list {
  display: flex;
  gap: var(--space-6);
  list-style: none;
}

.nav-list a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-interactive), border-color var(--transition-interactive);
}

.nav-list a:hover {
  color: var(--color-text);
  border-bottom-color: var(--color-primary);
}

.theme-toggle {
  padding: var(--space-2);
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  transition: color var(--transition-interactive), background var(--transition-interactive);
}
.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

/* Mobile nav */
.mobile-menu-btn {
  display: none;
  padding: var(--space-2);
  color: var(--color-text-muted);
}

@media (max-width: 768px) {
  .header { display: none; }
  .nav-list { display: none; }
  .mobile-menu-btn { display: none; }
  .nav-list.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-4);
    gap: var(--space-4);
  }
}

/* ===== HERO ===== */
.hero {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(250, 248, 243, 0.35) 0%,
    rgba(250, 248, 243, 0.6) 35%,
    rgba(250, 248, 243, 0.88) 65%,
    #faf8f3 100%
  );
}
[data-theme="dark"] .hero-overlay {
  background: linear-gradient(
    to bottom,
    rgba(26, 24, 20, 0.45) 0%,
    rgba(26, 24, 20, 0.65) 35%,
    rgba(26, 24, 20, 0.9) 65%,
    #1a1814 100%
  );
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-16) var(--space-4);
  max-width: var(--content-default);
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  text-shadow: 0 1px 8px rgba(250, 248, 243, 0.7), 0 0 20px rgba(250, 248, 243, 0.4);
}
[data-theme="dark"] .hero h1 {
  text-shadow: 0 1px 8px rgba(26, 24, 20, 0.8), 0 0 20px rgba(26, 24, 20, 0.5);
}

.hero-subtitle {
  font-size: var(--text-lg);
  color: var(--color-text);
  max-width: 56ch;
  margin-inline: auto;
  margin-bottom: var(--space-8);
  text-shadow: 0 1px 6px rgba(250, 248, 243, 0.6), 0 0 16px rgba(250, 248, 243, 0.3);
}
[data-theme="dark"] .hero-subtitle {
  text-shadow: 0 1px 6px rgba(26, 24, 20, 0.7), 0 0 16px rgba(26, 24, 20, 0.4);
}

.hero-quote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-base);
  color: var(--color-text);
  max-width: 50ch;
  margin-inline: auto;
  padding: var(--space-4);
  border-left: 3px solid var(--color-primary);
  text-align: left;
  background: rgba(255, 249, 240, 0.88);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
[data-theme="dark"] .hero-quote {
  background: rgba(32, 30, 25, 0.88);
}

/* ===== SECTIONS ===== */
.section {
  padding: clamp(var(--space-12), 6vw, var(--space-24)) var(--space-4);
}

.section-inner {
  max-width: var(--content-wide);
  margin-inline: auto;
}

.section-narrow {
  max-width: var(--content-default);
  margin-inline: auto;
}

.section-header {
  margin-bottom: var(--space-10);
}

.section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.section-desc {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 60ch;
}

.section-alt {
  background: var(--color-surface);
}

/* ===== WORLD SECTION ===== */
.world-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: center;
}

@media (max-width: 768px) {
  .world-grid { grid-template-columns: 1fr; }
}

.world-image {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.world-image img {
  width: 100%;
  display: block;
}

.world-facts {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.fact-item {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.fact-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-highlight);
  border-radius: var(--radius-md);
  color: var(--color-primary);
}

.fact-content h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.fact-content p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* ===== PILLARS ===== */
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: var(--space-6);
}

.pillar-card {
  background: var(--color-surface);
  border: 1px solid rgba(44, 38, 24, 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: box-shadow var(--transition-interactive), transform var(--transition-interactive);
}

.pillar-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.pillar-number {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-primary-highlight);
  line-height: 1;
  margin-bottom: var(--space-3);
}

.pillar-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.pillar-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ===== CHARACTERS — Grid + Overlay Card ===== */
.char-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-bottom: var(--space-4);
}
@media (min-width: 640px)  { .char-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1024px) { .char-grid { grid-template-columns: repeat(5, 1fr); gap: 16px; } }

.char-card {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.06);
  background: var(--color-surface-offset);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.char-card:active { transform: scale(0.97); }
@media (hover: hover) {
  .char-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.3); }
  .char-card:hover .char-card-img { transform: scale(1.05); }
  .char-card:hover::after { opacity: 1; animation: card-shimmer 0.6s ease-out forwards; }
}

/* 포트레이트 이미지 */
.char-card-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 0%;
  transition: transform 0.5s ease;
}

/* 하단 그라데이션 오버레이 + 텍스트 */
.char-card-overlay {
  position: absolute;
  inset-inline: 0; bottom: 0;
  z-index: 1;
  background: linear-gradient(to top, rgba(20,16,12,0.92) 0%, rgba(20,16,12,0.5) 60%, transparent 100%);
  padding: 48px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.char-card-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin: 4px 0 2px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.char-card-role {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.01em;
}

/* 진영 뱃지 */
.char-faction {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.faction-demon  { color: #ff8a8a; background: rgba(200,60,60,0.25); }
.faction-human  { color: #8ab4ff; background: rgba(60,100,200,0.25); }
.faction-neutral { color: #c8a84e; background: rgba(200,168,78,0.2); }
.faction-vassal { color: #d4a94e; background: rgba(180,140,60,0.2); }

/* 시머 효과 */
.char-card::after {
  content: '';
  position: absolute; inset: 0; z-index: 3;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.12) 45%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.12) 55%, transparent 60%);
  transform: translateX(-100%) rotate(-15deg);
  opacity: 0;
  transition: opacity 0.3s ease;
}
@keyframes card-shimmer { to { transform: translateX(100%) rotate(-15deg); } }

/* ===== SCENARIO SECTION ===== */
.scenario-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

@media (max-width: 768px) {
  .scenario-wrapper { grid-template-columns: 1fr; }
}

.scenario-card {
  background: var(--color-surface);
  border: 1px solid rgba(44, 38, 24, 0.06);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-interactive);
}

.scenario-card:hover {
  box-shadow: var(--shadow-md);
}

.scenario-header {
  padding: var(--space-6) var(--space-6) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.scenario-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.scenario-icon.demon {
  background: var(--color-demon-light);
  color: var(--color-demon);
}
.scenario-icon.human {
  background: var(--color-human-light);
  color: var(--color-human);
}

.scenario-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.scenario-card h3 span {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.scenario-body {
  padding: 0 var(--space-6) var(--space-6);
}

.scenario-body p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-3);
}

.scenario-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.stat {
  text-align: center;
  padding: var(--space-3);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: 2px;
}

/* ===== SCENARIO VISUAL (VS image area) ===== */
.scenario-visual {
  margin-bottom: var(--space-8);
}

.scenario-visual-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  align-items: stretch;
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 280px;
}

.scenario-visual-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.demon-slot {
  background: var(--color-demon-light);
}
.human-slot {
  background: var(--color-human-light);
}

.scenario-visual-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-faint);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
}

.scenario-visual-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-4);
  background: var(--color-surface-offset);
}

.scenario-visual-divider span {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text-faint);
  letter-spacing: 0.05em;
}

@media (max-width: 640px) {
  .scenario-visual-grid {
    min-height: 180px;
  }
}

.scenario-note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  margin-top: var(--space-3);
  font-style: italic;
}



/* ===== GALLERY POPUP ===== */
.gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out);
}
.gallery-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.gallery-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(0 0 0 / 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.gallery-container {
  position: relative;
  width: min(95vw, 960px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 24px 64px oklch(0 0 0 / 0.4);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.3s var(--ease-out);
}
.gallery-overlay.open .gallery-container {
  transform: translateY(0) scale(1);
}

/* 모달 본문: 데스크탑 2패널 / 모바일 세로 스크롤 */
.modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* 좌측 포트레이트 */
.modal-portrait {
  flex: 0 0 40%;
  position: relative;
  overflow: hidden;
  background: var(--color-surface-offset);
}
.modal-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
  cursor: zoom-in;
}

/* 우측 정보 패널 */
.modal-info-panel {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* 캐릭터 정보 */
.modal-char-info { display: flex; flex-direction: column; gap: 6px; }
.modal-char-role { font-size: var(--text-xs); color: var(--color-text-faint); }
.modal-char-desc { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.6; margin: 0; }
.modal-char-quote {
  font-family: var(--font-display); font-style: italic;
  font-size: var(--text-sm); color: var(--color-text-muted);
  padding-top: var(--space-2); border-top: 1px solid var(--color-divider);
  margin: 0;
}

/* 갤러리 섹션 */
.modal-gallery-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.gallery-viewer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}

.gallery-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.gallery-close {
  padding: var(--space-2);
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  transition: color var(--transition-interactive), background var(--transition-interactive);
  cursor: pointer;
}
.gallery-close:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.gallery-body {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-2);
  flex: 1;
  min-height: 0;
}

.gallery-nav {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  transition: color var(--transition-interactive), background var(--transition-interactive);
  cursor: pointer;
}
.gallery-nav:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.gallery-image-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  aspect-ratio: 1216 / 832;
  max-height: 55vh;
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.gallery-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.gallery-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--color-divider);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gallery-counter {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  padding: var(--space-1) 0;
  flex-shrink: 0;
}

.gallery-tabs {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  padding: 0 var(--space-6) var(--space-2);
  flex-shrink: 0;
}

.gallery-tab {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-divider);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-interactive);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.gallery-tab:hover {
  color: var(--color-text);
  border-color: var(--color-border);
}
.gallery-tab.active {
  color: var(--color-text-inverse);
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.tab-count {
  font-size: 0.65rem;
  opacity: 0.6;
}

.nsfw-tab {
  border-color: oklch(0.6 0.15 15 / 0.3);
  color: oklch(0.6 0.15 15);
}
.nsfw-tab:hover {
  border-color: oklch(0.6 0.15 15 / 0.6);
}
.nsfw-tab.active {
  background: oklch(0.55 0.15 15);
  border-color: oklch(0.55 0.15 15);
  color: #fff;
}

.gallery-thumbs {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-6) var(--space-4);
  overflow-x: auto;
  justify-content: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.gallery-thumb {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-offset);
  cursor: pointer;
  transition: all var(--transition-interactive);
  white-space: nowrap;
}
.gallery-thumb:hover {
  background: var(--color-surface-offset-2);
  color: var(--color-text);
}
.gallery-thumb.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

/* Gallery mobile adjustments */
@media (max-width: 768px) {
  .gallery-overlay { z-index: 10000; }
  .gallery-container {
    position: fixed; inset: 0;
    width: 100%; height: 100dvh; max-height: 100dvh;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-body {
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-portrait {
    flex: none;
    aspect-ratio: 3/4;
    max-height: 50vh;
  }
  .modal-info-panel {
    flex: none;
    overflow: visible;
    padding: var(--space-3) var(--space-4);
  }
  .gallery-viewer { padding: 0; }
  .gallery-nav { width: 32px; height: 32px; }
  .gallery-image-wrap { aspect-ratio: auto; max-height: 40vh; }
  .gallery-thumbs { padding: 0 var(--space-3) var(--space-3); }
}

/* Char card clickable cursor */
.char-card {
  cursor: pointer;
}

/* ===== SCROLL ANIMATIONS ===== */
.fade-in { opacity: 1; }

@supports (animation-timeline: scroll()) {
  .fade-in {
    opacity: 0;
    animation: reveal-fade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 100%;
  }
}

@keyframes reveal-fade {
  to { opacity: 1; }
}
