/* ============================================================
   HELLO ABYSS — Hermetic Celestial Cathedral
   Design System v1.0
   ============================================================ */

:root {
  /* Core Palette — The Abyss */
  --abyss-void: #050410;
  --abyss-deep: #0a0a1a;
  --abyss-mid: #131225;
  --abyss-night: #1a1538;
  --abyss-veil: #221b48;

  /* Sacred Gold */
  --gold-100: #fff4c2;
  --gold-200: #f4d03f;
  --gold-300: #d4af37;
  --gold-400: #b8941f;
  --gold-500: #8a6d12;
  --gold-glow: rgba(212, 175, 55, 0.5);

  /* Mystic Purple */
  --violet-100: #c9b6f5;
  --violet-200: #9b7fde;
  --violet-300: #6b4ea8;
  --violet-400: #4a3478;
  --violet-glow: rgba(155, 127, 222, 0.4);

  /* Blood Crimson */
  --crimson-100: #ff6b6b;
  --crimson-200: #c0392b;
  --crimson-300: #8b0000;
  --crimson-400: #5a0000;

  /* Ethereal Silver */
  --silver-100: #f5f3ff;
  --silver-200: #d4d0e8;
  --silver-300: #9b9bb8;
  --silver-400: #6b6b85;

  /* Surface */
  --surface-1: rgba(255, 255, 255, 0.03);
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.08);
  --surface-hover: rgba(212, 175, 55, 0.08);

  /* Border */
  --border-1: rgba(212, 175, 55, 0.15);
  --border-2: rgba(212, 175, 55, 0.25);
  --border-strong: rgba(212, 175, 55, 0.5);

  /* Text */
  --text-1: #f5f3ff;
  --text-2: #d4d0e8;
  --text-3: #9b9bb8;
  --text-4: #6b6b85;
  --text-gold: #d4af37;

  /* Effects */
  --shadow-deep: 0 20px 80px rgba(0, 0, 0, 0.6);
  --shadow-gold: 0 0 40px rgba(212, 175, 55, 0.25);
  --shadow-violet: 0 0 40px rgba(155, 127, 222, 0.25);
  --shadow-inner: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  /* Typography */
  --font-display: 'Cinzel', 'Noto Serif KR', serif;
  --font-serif: 'Cormorant Garamond', 'Noto Serif KR', serif;
  --font-sub: 'Marcellus', 'Noto Serif KR', serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-kr: 'Noto Serif KR', serif;

  /* Spacing */
  --sidebar-w: 280px;
  --topbar-h: 64px;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --radius-xl: 24px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--abyss-void);
  color: var(--text-1);
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.abyss-body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(107, 78, 168, 0.15), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(139, 0, 0, 0.1), transparent 50%),
    linear-gradient(180deg, var(--abyss-void) 0%, var(--abyss-deep) 100%);
  min-height: 100vh;
  position: relative;
}

a {
  color: var(--gold-300);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--gold-200); }

::selection { background: var(--gold-300); color: var(--abyss-void); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--abyss-deep); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--violet-400), var(--gold-500));
  border-radius: 10px;
  border: 2px solid var(--abyss-deep);
}
::-webkit-scrollbar-thumb:hover { background: var(--gold-300); }

/* ============================================================
   COSMIC BACKGROUND
   ============================================================ */
.abyss-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.abyss-bg__stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, white, transparent),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 50% 20%, var(--gold-200), transparent),
    radial-gradient(1px 1px at 80% 10%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 10% 80%, rgba(212,175,55,0.6), transparent),
    radial-gradient(1px 1px at 90% 40%, white, transparent),
    radial-gradient(1px 1px at 30% 90%, rgba(155,127,222,0.8), transparent),
    radial-gradient(2px 2px at 70% 60%, rgba(255,255,255,0.4), transparent);
  background-size: 800px 800px;
  animation: starfield 200s linear infinite;
  opacity: 0.5;
}

.abyss-bg__nebula {
  position: absolute;
  width: 100%; height: 100%;
  background:
    radial-gradient(circle at 30% 40%, rgba(107, 78, 168, 0.2), transparent 50%),
    radial-gradient(circle at 70% 60%, rgba(139, 0, 0, 0.12), transparent 50%);
  animation: nebula 30s ease-in-out infinite alternate;
  filter: blur(60px);
}

.abyss-bg__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.6) 100%);
}

@keyframes starfield {
  from { background-position: 0 0; }
  to { background-position: -800px -800px; }
}

@keyframes nebula {
  0% { transform: scale(1) rotate(0deg); opacity: 0.5; }
  100% { transform: scale(1.2) rotate(15deg); opacity: 0.9; }
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.font-display { font-family: var(--font-display); letter-spacing: 0.04em; }
.font-serif { font-family: var(--font-serif); }
.font-sub { font-family: var(--font-sub); letter-spacing: 0.06em; }
.font-mono { font-family: var(--font-mono); }
.font-kr { font-family: var(--font-kr); }

.text-gold { color: var(--gold-300); }
.text-gold-200 { color: var(--gold-200); }
.text-violet { color: var(--violet-200); }
.text-crimson { color: var(--crimson-100); }
.text-muted { color: var(--text-3); }
.text-faint { color: var(--text-4); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.04em; }

.gold-gradient-text {
  background: linear-gradient(135deg, var(--gold-100) 0%, var(--gold-300) 50%, var(--gold-400) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.crimson-gradient-text {
  background: linear-gradient(135deg, var(--crimson-100), var(--gold-300));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============================================================
   GATE (Entry)
   ============================================================ */
.gate {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  z-index: 1;
}

.gate__veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 0%, var(--abyss-void) 80%);
  pointer-events: none;
}

.gate__card {
  position: relative;
  max-width: 480px;
  width: 100%;
  padding: 56px 48px;
  background: linear-gradient(180deg, rgba(26, 21, 56, 0.85), rgba(10, 10, 26, 0.95));
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-deep), var(--shadow-gold), var(--shadow-inner);
  backdrop-filter: blur(20px);
  text-align: center;
}

.gate__sigil {
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
  position: relative;
  animation: rotate-slow 60s linear infinite;
}

.gate__sigil svg { width: 100%; height: 100%; }

@keyframes rotate-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.gate__title {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.18em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.gate__subtitle {
  font-family: var(--font-sub);
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 40px;
}

.gate__input-wrap {
  position: relative;
  margin-bottom: 20px;
}

.gate__input {
  width: 100%;
  padding: 18px 20px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-m);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.15em;
  text-align: center;
  transition: all 0.3s;
  outline: none;
}

.gate__input:focus {
  border-color: var(--gold-300);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15), var(--shadow-gold);
  background: rgba(0,0,0,0.6);
}

.gate__hint {
  color: var(--text-4);
  font-size: 12px;
  font-style: italic;
  margin-top: 16px;
  letter-spacing: 0.1em;
}

.gate__error {
  color: var(--crimson-100);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
  letter-spacing: 0.08em;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-m);
  font-family: var(--font-sub);
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-1);
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: middle;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  min-height: 44px;
}

.btn > i {
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  border-color: var(--gold-300);
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-gold);
}

.btn:active { transform: translateY(0); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold-300), var(--gold-400));
  color: var(--abyss-void);
  border-color: var(--gold-200);
  font-weight: 700;
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-200), var(--gold-300));
  box-shadow: 0 0 30px var(--gold-glow);
}

.btn-violet {
  background: linear-gradient(135deg, var(--violet-300), var(--violet-400));
  border-color: var(--violet-200);
  color: var(--text-1);
}

.btn-crimson {
  background: linear-gradient(135deg, var(--crimson-300), var(--crimson-400));
  border-color: var(--crimson-200);
  color: var(--text-1);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-1);
}

.btn-icon {
  width: 40px; height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--radius-s);
  line-height: 1;
}

.btn-icon > i {
  margin: 0;
  font-size: 14px;
}

.btn-block { width: 100%; }

.btn-lg { padding: 16px 32px; font-size: 14px; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(10, 10, 26, 0.85), rgba(5, 4, 16, 0.95));
  border-right: 1px solid var(--border-1);
  backdrop-filter: blur(20px);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar__brand {
  padding: 8px 12px 24px;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: 20px;
}

.sidebar__brand-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar__brand-sub {
  font-family: var(--font-sub);
  font-size: 10px;
  letter-spacing: 0.4em;
  color: var(--text-4);
  text-transform: uppercase;
  margin-top: 4px;
}

.sidebar__section-label {
  font-family: var(--font-sub);
  font-size: 10px;
  letter-spacing: 0.35em;
  color: var(--text-4);
  text-transform: uppercase;
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  color: var(--text-2);
  font-family: var(--font-sub);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.nav-item i { width: 18px; text-align: center; color: var(--gold-400); font-size: 14px; }
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--gold-200);
  border-color: var(--border-1);
}
.nav-item:hover i { color: var(--gold-200); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.18), rgba(212, 175, 55, 0.05));
  color: var(--gold-100);
  border-color: var(--border-2);
  box-shadow: var(--shadow-inner);
}
.nav-item.active i { color: var(--gold-200); }

.sidebar__footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: linear-gradient(180deg, rgba(10, 10, 26, 0.85), rgba(10, 10, 26, 0.5));
  border-bottom: 1px solid var(--border-1);
  backdrop-filter: blur(20px);
}

.topbar__title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-200);
}

.topbar__search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.topbar__search input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-m);
  color: var(--text-1);
  font-family: var(--font-serif);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.topbar__search input:focus {
  border-color: var(--gold-300);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.topbar__search i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold-400);
}

.topbar__search .kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
  padding: 2px 6px;
  border: 1px solid var(--border-1);
  border-radius: 4px;
}

.content {
  flex: 1;
  padding: 32px 36px 80px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-1);
}

.page-header__title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.page-header__subtitle {
  font-family: var(--font-sub);
  font-size: 12px;
  letter-spacing: 0.35em;
  color: var(--text-4);
  text-transform: uppercase;
}

.page-header__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.panel {
  background: linear-gradient(180deg, rgba(26, 21, 56, 0.5), rgba(10, 10, 26, 0.7));
  border: 1px solid var(--border-1);
  border-radius: var(--radius-l);
  padding: 24px;
  box-shadow: var(--shadow-inner);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-300), transparent);
  opacity: 0.4;
}

.panel-title {
  font-family: var(--font-sub);
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title i { color: var(--gold-300); }

/* Card grid */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.card {
  background: linear-gradient(180deg, rgba(26, 21, 56, 0.5), rgba(10, 10, 26, 0.8));
  border: 1px solid var(--border-1);
  border-radius: var(--radius-l);
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-2);
  box-shadow: var(--shadow-deep), var(--shadow-gold);
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--gold-glow), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.card:hover::after { opacity: 0.3; }

.card__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text-1);
  letter-spacing: 0.04em;
}

.card__meta {
  font-family: var(--font-sub);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-4);
  text-transform: uppercase;
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Stat card */
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-l);
  position: relative;
  overflow: hidden;
}

.stat__label {
  font-family: var(--font-sub);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--text-3);
  text-transform: uppercase;
}

.stat__value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.stat__icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  color: var(--gold-400);
  opacity: 0.25;
}

/* ============================================================
   CODEX EDITOR
   ============================================================ */
.codex-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: calc(100vh - var(--topbar-h));
  margin: -32px -36px 0;
}

.codex-list {
  background: rgba(5, 4, 16, 0.6);
  border-right: 1px solid var(--border-1);
  overflow-y: auto;
  padding: 16px 12px;
}

.codex-list__item {
  padding: 12px 14px;
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.codex-list__item:hover {
  background: var(--surface-hover);
  border-color: var(--border-1);
}

.codex-list__item.active {
  background: var(--surface-hover);
  border-color: var(--border-2);
  box-shadow: var(--shadow-inner);
}

.codex-list__title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-1);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.codex-list__excerpt {
  font-size: 12px;
  color: var(--text-4);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.codex-list__meta {
  font-family: var(--font-sub);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-4);
  text-transform: uppercase;
  margin-top: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.codex-editor {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.codex-editor__header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(10, 10, 26, 0.6);
}

.codex-editor__title-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-1);
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.codex-editor__body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 40px 80px;
}

.codex-editor__textarea {
  width: 100%;
  min-height: 60vh;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-1);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.8;
}

/* Seal badge */
.seal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-family: var(--font-sub);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid;
}

.seal-0 { color: var(--silver-300); border-color: var(--border-1); }
.seal-1 { color: var(--violet-200); border-color: var(--violet-300); background: rgba(107, 78, 168, 0.15); }
.seal-2 { color: var(--gold-200); border-color: var(--gold-400); background: rgba(212, 175, 55, 0.1); }
.seal-3 { color: var(--crimson-100); border-color: var(--crimson-300); background: rgba(139, 0, 0, 0.15); }

/* ============================================================
   GALLERY
   ============================================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-l);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  transition: all 0.25s;
}

.gallery-item:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: var(--gold-300);
  box-shadow: var(--shadow-deep), 0 0 30px var(--gold-glow);
  z-index: 2;
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s;
}

.gallery-item:hover img,
.gallery-item:hover video { transform: scale(1.05); }

/* Video play badge */
.gallery-item__play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: 2px solid var(--gold-300, #d4af37);
  color: var(--gold-300, #d4af37);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  pointer-events: none;
  box-shadow: 0 0 30px rgba(212,175,55,0.45);
  backdrop-filter: blur(2px);
  z-index: 2;
}
.gallery-item[data-kind="video"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.0) 60%, rgba(0,0,0,0.5));
  pointer-events: none;
}

/* Upload button overlay — ensure button can host absolute overlay */
.btn { position: relative; }

.gallery-item__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.85));
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  align-items: flex-end;
  padding: 14px;
}

.gallery-item:hover .gallery-item__overlay { opacity: 1; }

.gallery-item__info {
  color: var(--text-1);
  font-family: var(--font-sub);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.gallery-item__select {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  border: 2px solid white;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
}

.gallery-item.selected .gallery-item__select {
  display: flex;
  background: var(--gold-300);
  color: var(--abyss-void);
}

.gallery-item.selected {
  border-color: var(--gold-300);
  box-shadow: 0 0 0 3px var(--gold-300);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.lightbox.open { display: flex; }

.lightbox__img {
  max-width: 90vw;
  max-height: 85vh;
  border: 1px solid var(--border-strong);
  box-shadow: 0 0 60px var(--gold-glow);
  border-radius: var(--radius-m);
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  color: var(--gold-200);
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  width: 50px; height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.2s;
}
.lightbox__close { top: 24px; right: 24px; }
.lightbox__nav.prev { left: 24px; top: 50%; transform: translateY(-50%); }
.lightbox__nav.next { right: 24px; top: 50%; transform: translateY(-50%); }
.lightbox__close:hover, .lightbox__nav:hover {
  background: var(--gold-300);
  color: var(--abyss-void);
}

.lightbox__caption {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-2);
  font-family: var(--font-sub);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}

/* ============================================================
   AUDIO VAULT
   ============================================================ */
.audio-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.audio-row {
  display: grid;
  grid-template-columns: 40px 56px 1fr auto auto auto;
  gap: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-m);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.audio-row:hover {
  background: var(--surface-hover);
  border-color: var(--border-2);
}

.audio-row.playing {
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.12), transparent);
  border-color: var(--gold-300);
}

.audio-row__num {
  font-family: var(--font-mono);
  color: var(--text-4);
  font-size: 12px;
  text-align: center;
}

.audio-row__cover {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-s);
  background: linear-gradient(135deg, var(--violet-400), var(--abyss-night));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-300);
  font-size: 20px;
  overflow: hidden;
}

.audio-row__cover img { width: 100%; height: 100%; object-fit: cover; }

.audio-row__title {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--text-1);
  margin: 0 0 2px;
}

.audio-row__artist {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-sub);
  letter-spacing: 0.1em;
}

.audio-row__duration {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}

/* Mini player */
.mini-player {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(720px, calc(100% - 40px));
  background: linear-gradient(180deg, rgba(26, 21, 56, 0.95), rgba(10, 10, 26, 0.98));
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-deep), var(--shadow-gold);
  backdrop-filter: blur(20px);
  padding: 14px 20px;
  display: none;
  align-items: center;
  gap: 14px;
}

.mini-player.active { display: flex; }

.mini-player__cover {
  width: 44px; height: 44px;
  border-radius: var(--radius-s);
  background: linear-gradient(135deg, var(--violet-400), var(--gold-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-200);
  flex-shrink: 0;
}

.mini-player__info {
  flex: 1;
  min-width: 0;
}

.mini-player__title {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player__artist {
  font-size: 11px;
  font-family: var(--font-sub);
  letter-spacing: 0.15em;
  color: var(--text-3);
  text-transform: uppercase;
}

.mini-player__controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-player__btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  color: var(--gold-200);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.mini-player__btn:hover { background: var(--gold-300); color: var(--abyss-void); }

.mini-player__btn.play {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--gold-300), var(--gold-400));
  color: var(--abyss-void);
  border-color: var(--gold-200);
}

.mini-player__progress {
  flex: 1;
  height: 4px;
  background: var(--surface-3);
  border-radius: 100px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.mini-player__progress-fill {
  position: absolute;
  inset: 0 100% 0 0;
  background: linear-gradient(90deg, var(--gold-300), var(--gold-200));
  border-radius: 100px;
  transition: right 0.1s linear;
}

.mini-player__time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  min-width: 80px;
  text-align: right;
}

/* ============================================================
   FORMS
   ============================================================ */
.input, .textarea, .select {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-m);
  color: var(--text-1);
  font-family: var(--font-serif);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--gold-300);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.textarea { resize: vertical; min-height: 100px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-family: var(--font-sub);
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--text-3);
  text-transform: uppercase;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal {
  width: 100%;
  max-width: 520px;
  background: linear-gradient(180deg, rgba(26, 21, 56, 0.95), rgba(10, 10, 26, 0.98));
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-deep), var(--shadow-gold);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.1em;
  margin: 0 0 24px;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ============================================================
   DROP ZONE
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-l);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: var(--surface-1);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--gold-300);
  background: var(--surface-hover);
  box-shadow: var(--shadow-gold);
}

.dropzone i {
  font-size: 42px;
  color: var(--gold-400);
  margin-bottom: 14px;
}

.dropzone__text {
  font-family: var(--font-sub);
  letter-spacing: 0.15em;
  color: var(--text-2);
  text-transform: uppercase;
  font-size: 13px;
}

.dropzone__hint {
  margin-top: 8px;
  color: var(--text-4);
  font-size: 12px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: linear-gradient(135deg, rgba(26, 21, 56, 0.98), rgba(10, 10, 26, 0.98));
  border: 1px solid var(--border-2);
  border-radius: var(--radius-m);
  padding: 14px 20px;
  color: var(--text-1);
  font-family: var(--font-serif);
  font-size: 14px;
  box-shadow: var(--shadow-deep), var(--shadow-gold);
  pointer-events: auto;
  min-width: 260px;
  animation: toast-in 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast.success { border-color: var(--gold-300); }
.toast.error { border-color: var(--crimson-200); }
.toast i { color: var(--gold-300); }
.toast.success i { color: var(--gold-300); }
.toast.error i { color: var(--crimson-100); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   COMMAND PALETTE (NEXUS)
   ============================================================ */
.nexus-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  z-index: 800;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.nexus-backdrop.open { display: flex; }

.nexus {
  width: min(640px, 92vw);
  background: linear-gradient(180deg, rgba(26, 21, 56, 0.98), rgba(10, 10, 26, 0.99));
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-deep), 0 0 80px var(--gold-glow);
  overflow: hidden;
}

.nexus__input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-1);
  outline: none;
  color: var(--text-1);
  padding: 18px 24px 18px 60px;
  font-family: var(--font-serif);
  font-size: 18px;
}

.nexus__input-wrap {
  position: relative;
}

.nexus__input-wrap i {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold-300);
  font-size: 16px;
}

.nexus__results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px;
}

.nexus__group-label {
  font-family: var(--font-sub);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--text-4);
  text-transform: uppercase;
  padding: 14px 16px 8px;
}

.nexus__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-s);
  cursor: pointer;
  color: var(--text-2);
}

.nexus__item:hover,
.nexus__item.active {
  background: var(--surface-hover);
  color: var(--gold-100);
}

.nexus__item i { color: var(--gold-400); width: 18px; }

.nexus__item-meta {
  margin-left: auto;
  font-family: var(--font-sub);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-4);
  text-transform: uppercase;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-3);
}

.empty-state i {
  font-size: 48px;
  color: var(--gold-400);
  opacity: 0.4;
  margin-bottom: 16px;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.empty-state__text {
  font-size: 14px;
  color: var(--text-4);
  max-width: 400px;
  margin: 0 auto;
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-2), transparent);
  margin: 24px 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-family: var(--font-sub);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  color: var(--text-2);
}

/* Toolbar tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-1);
  flex-wrap: wrap;
  align-items: stretch;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  font-family: var(--font-sub);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  min-height: 40px;
}

.tab:hover { color: var(--gold-200); }
.tab.active {
  color: var(--gold-200);
  border-color: var(--gold-300);
}

/* Loader */
.loader {
  display: inline-block;
  width: 22px; height: 22px;
  border: 2px solid var(--border-1);
  border-top-color: var(--gold-300);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.55); border-color: var(--gold-300); }
  50% { box-shadow: 0 0 0 18px rgba(212, 175, 55, 0); border-color: var(--gold-200); }
}

/* ============================================================
   REFRESH SYSTEM — Floating Button + Pull Indicator
   ============================================================ */
.abyss-refresh-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--gold-200), var(--gold-300) 60%, var(--gold-500));
  color: var(--abyss-void);
  border: 1px solid var(--gold-100);
  font-size: 18px;
  cursor: pointer;
  box-shadow:
    0 4px 24px rgba(212, 175, 55, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(.2,.9,.3,1.4), box-shadow 0.3s, opacity 0.3s;
  opacity: 0.92;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.abyss-refresh-btn:hover {
  transform: rotate(180deg) scale(1.08);
  box-shadow: 0 6px 32px rgba(212, 175, 55, 0.7), 0 0 0 1px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.4);
  opacity: 1;
}
.abyss-refresh-btn:active {
  transform: rotate(360deg) scale(0.94);
}
.abyss-refresh-btn.refreshing i,
.abyss-refresh-btn:active i {
  animation: spin-gold 0.9s linear infinite;
}
@keyframes spin-gold {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}

.refresh-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -80px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 16, 50, 0.95), rgba(5, 4, 16, 0.95));
  border: 1px solid var(--gold-300);
  box-shadow: 0 4px 24px rgba(212, 175, 55, 0.5), inset 0 0 12px rgba(212, 175, 55, 0.2);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-200);
  font-size: 20px;
  opacity: 0;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
  pointer-events: none;
}
.refresh-indicator.ready {
  border-color: var(--gold-100);
  box-shadow: 0 4px 32px rgba(212, 175, 55, 0.85), inset 0 0 18px rgba(212, 175, 55, 0.4);
}
.refresh-indicator.ready i {
  color: var(--gold-100);
  animation: pulse-glow 0.6s ease-in-out infinite alternate;
}
.refresh-indicator.refreshing {
  opacity: 1 !important;
  transform: translate(-50%, 30px) !important;
}
.refresh-indicator.refreshing i {
  animation: spin-gold 0.9s linear infinite;
}
@keyframes pulse-glow {
  from { text-shadow: 0 0 4px var(--gold-300); }
  to   { text-shadow: 0 0 16px var(--gold-100), 0 0 24px var(--gold-200); }
}

@media (max-width: 640px) {
  .abyss-refresh-btn {
    bottom: 86px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}

/* ============================================================
   MYSTICAL EFFECTS — Hover glow, Trail, Loading Sigil
   ============================================================ */
.glow-hover {
  transition: box-shadow 0.4s ease, transform 0.3s ease, border-color 0.3s;
}
.glow-hover:hover {
  box-shadow: 0 0 0 1px var(--gold-300), 0 0 24px rgba(212, 175, 55, 0.45);
  border-color: var(--gold-200);
}

.abyss-trail-dot {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-100), var(--gold-300) 60%, transparent);
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: screen;
  filter: blur(0.5px);
  animation: trail-fade 800ms ease-out forwards;
}
@keyframes trail-fade {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.3) translateY(20px); }
}

.loading-sigil {
  width: 64px;
  height: 64px;
  display: inline-block;
  position: relative;
  border-radius: 50%;
  border: 1px solid var(--gold-300);
  border-top-color: transparent;
  animation: spin-gold 1.4s linear infinite;
}
.loading-sigil::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid var(--violet-200);
  border-bottom-color: transparent;
  animation: spin-gold 0.9s linear infinite reverse;
}

/* ============================================================
   CINEMATIC GATE ENTRANCE — Veil Splitting + Gold Burst
   ============================================================ */
.gate-veil {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  display: flex;
}
.gate-veil__left,
.gate-veil__right {
  flex: 1;
  background: linear-gradient(180deg, #050410 0%, #0a0a1a 50%, #050410 100%);
  border-right: 1px solid rgba(212, 175, 55, 0.3);
  transition: transform 1.4s cubic-bezier(.7, 0, .2, 1);
}
.gate-veil__left  { transform-origin: left center;  }
.gate-veil__right { transform-origin: right center; }
.gate-veil.open .gate-veil__left  { transform: translateX(-105%); }
.gate-veil.open .gate-veil__right { transform: translateX(105%); }

.gate-burst {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-100), var(--gold-300));
  transform: translate(-50%, -50%) scale(1);
  box-shadow: 0 0 60px 20px var(--gold-200), 0 0 120px 40px rgba(212, 175, 55, 0.5);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
}
.gate-burst.fire {
  animation: gate-burst-anim 1.6s cubic-bezier(.2,.6,.2,1) forwards;
}
@keyframes gate-burst-anim {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(2); }
  60%  { opacity: 0.7; transform: translate(-50%, -50%) scale(40); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(80); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 20px 16px 80px; }
  .codex-layout { grid-template-columns: 1fr; margin: 0; height: auto; }
  .codex-list { max-height: 40vh; }
  .page-header__title { font-size: 26px; }
}

@media (max-width: 640px) {
  .page-header {
    align-items: flex-start;
    gap: 14px;
  }
  .page-header__actions {
    width: 100%;
    gap: 8px;
  }
  .page-header__actions .btn {
    flex: 1 1 calc(50% - 8px);
    padding: 12px 12px;
    font-size: 11px;
    letter-spacing: 0.14em;
  }
  .page-header__actions .btn-icon {
    flex: 0 0 40px;
  }
  .btn {
    padding: 11px 16px;
    font-size: 12px;
    letter-spacing: 0.14em;
  }
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 12px 14px;
    font-size: 10px;
    letter-spacing: 0.2em;
  }
  #bulk-bar {
    padding: 10px 12px !important;
  }
  #bulk-bar .btn {
    flex: 1 1 calc(50% - 6px);
  }
  .dropzone {
    padding: 28px 14px;
  }
  .audio-row {
    gap: 8px;
  }
  .modal {
    width: calc(100vw - 24px);
    max-width: 100%;
  }
}
