:root {
  --bg-color: #080412;
  --card-bg: rgba(23, 13, 45, 0.8);
  --card-border: rgba(168, 85, 247, 0.35);
  --accent-purple: #9333ea;
  --accent-neon: #c084fc;
  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --text-main: #f3e8ff;
  --text-muted: #a855f7;
  --nav-bg: rgba(12, 7, 26, 0.92);
  --lux-neon-text: 0 0 6px rgba(199, 153, 255, 0.58), 0 0 16px rgba(168, 85, 247, 0.38), 0 0 32px rgba(88, 28, 135, 0.24);
  --lux-neon-icon: drop-shadow(0 0 5px rgba(199, 153, 255, 0.62)) drop-shadow(0 0 14px rgba(168, 85, 247, 0.42)) drop-shadow(0 0 28px rgba(88, 28, 135, 0.28));
  --lux-neon-box: 0 0 0 1px rgba(199, 153, 255, 0.14), 0 0 20px rgba(168, 85, 247, 0.42), 0 0 42px rgba(88, 28, 135, 0.24), inset 0 1px 0 rgba(199, 153, 255, 0.1);
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-corner {
  background: transparent !important;
  border: 0 !important;
}

html,
body,
.app,
.view-pane,
.sheet-content {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.app::-webkit-scrollbar,
.view-pane::-webkit-scrollbar,
.sheet-content::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent !important;
}

body {
  background:
    linear-gradient(180deg, rgba(5, 3, 14, 0.62), rgba(5, 3, 14, 0.94)),
    url("assets/backgrounds/miti-city-bg.webp") top center / cover fixed no-repeat,
    var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  position: relative;
  scrollbar-width: none;
}

.pwa-network-status {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 5000;
  width: min(440px, calc(100% - 24px));
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid rgba(236, 72, 153, 0.5);
  border-radius: 8px;
  background: rgba(16, 8, 31, 0.96);
  color: #f8edff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.pwa-network-status[hidden] {
  display: none;
}

body.theme-light .pwa-network-status {
  border-color: rgba(255, 91, 168, 0.48);
  background: rgba(255, 247, 252, 0.97);
  color: #73304f;
  box-shadow: 0 12px 28px rgba(130, 57, 90, 0.16);
}

body::-webkit-scrollbar,
.app::-webkit-scrollbar,
.view-pane::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body.theme-light {
  --bg-color: #fff5f8;
  --card-bg: rgba(255, 247, 252, 0.84);
  --card-border: rgba(196, 114, 244, 0.3);
  --accent-purple: #a855f7;
  --accent-neon: #b469ff;
  --accent-pink: #ff4fa3;
  --accent-cyan: #06b6d4;
  --text-main: #251334;
  --text-muted: #74469a;
  --nav-bg: rgba(255, 247, 252, 0.9);
  --lux-neon-text: 0 0 6px rgba(255, 91, 168, 0.46), 0 0 16px rgba(201, 77, 146, 0.3), 0 0 30px rgba(126, 62, 150, 0.18);
  --lux-neon-icon: drop-shadow(0 0 5px rgba(255, 91, 168, 0.5)) drop-shadow(0 0 14px rgba(201, 77, 146, 0.34)) drop-shadow(0 0 28px rgba(126, 62, 150, 0.18));
  --lux-neon-box: 0 0 0 1px rgba(255, 91, 168, 0.22), 0 0 20px rgba(255, 91, 168, 0.34), 0 0 42px rgba(126, 62, 150, 0.16), inset 0 1px 0 rgba(255, 145, 196, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 249, 253, 0.78), rgba(255, 240, 248, 0.94)),
    url("assets/backgrounds/miti-city-bg.webp") top center / cover fixed no-repeat,
    var(--bg-color);
}

body.theme-light .header {
  background: rgba(255, 239, 226, 0.9);
  border-bottom-color: rgba(255, 92, 166, 0.24);
  box-shadow: 0 12px 28px rgba(154, 79, 103, 0.08);
}

body.theme-light .glow-bg {
  background: radial-gradient(circle, rgba(255, 79, 163, 0.28) 0%, rgba(255, 255, 255, 0) 70%);
}

body.theme-light .glow-bg-secondary {
  background: radial-gradient(circle, rgba(244, 114, 182, 0.18) 0%, rgba(255, 255, 255, 0) 70%);
}

body.theme-light .logo {
  background: linear-gradient(135deg, #ff8bc7 0%, #ff4fa3 55%, #7c2d12 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

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

.welcome-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 1, 7, 0.72);
  backdrop-filter: blur(10px);
}

.welcome-modal-panel {
  position: relative;
  width: min(420px, 100%);
  border: 1px solid rgba(192, 132, 252, 0.42);
  border-radius: 22px;
  background:
    radial-gradient(circle at 82% 0%, rgba(236, 72, 153, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(24, 13, 45, 0.98), rgba(10, 4, 22, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
  padding: 26px 22px 22px;
}

.welcome-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(192, 132, 252, 0.36);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(243, 232, 255, 0.9);
  font-size: 24px;
  line-height: 1;
}

.welcome-modal-kicker {
  color: var(--accent-neon);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.welcome-modal-panel h2 {
  margin: 10px 42px 12px 0;
  color: #fff;
  font-size: 30px;
  line-height: 1.05;
}

.welcome-modal-panel p {
  margin: 0;
  color: rgba(223, 190, 255, 0.86);
  font-size: 15px;
  line-height: 1.5;
}

.welcome-modal-actions {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.welcome-modal-actions button {
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid rgba(192, 132, 252, 0.45);
  background: rgba(123, 31, 255, 0.18);
  color: #fff;
  font-weight: 800;
}

.welcome-modal-actions button:first-child {
  background: linear-gradient(135deg, #8b35ee, #f450b6);
  border-color: rgba(255, 159, 208, 0.62);
}

body.theme-light .welcome-modal-backdrop {
  background: rgba(48, 20, 32, 0.34);
}

body.theme-light .welcome-modal-panel {
  background:
    radial-gradient(circle at 82% 0%, rgba(255, 79, 163, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(255, 246, 239, 0.98), rgba(244, 221, 211, 0.96));
  border-color: rgba(255, 92, 166, 0.32);
  box-shadow: 0 22px 62px rgba(154, 79, 103, 0.24);
}

body.theme-light .welcome-modal-close {
  background: rgba(255, 231, 221, 0.78);
  border-color: rgba(255, 74, 155, 0.35);
  color: #b43367;
}

body.theme-light .welcome-modal-kicker,
body.theme-light .welcome-modal-panel h2 {
  color: #8a3156;
}

body.theme-light .welcome-modal-panel p {
  color: #9e4967;
}

body.theme-light .welcome-modal-actions button {
  background: rgba(255, 97, 147, 0.12);
  border-color: rgba(197, 55, 107, 0.34);
  color: #8a3156;
}

body.theme-light .welcome-modal-actions button:first-child {
  background: linear-gradient(135deg, #ff7fbd, #b74577);
  color: #fff8fb;
}

.admin-login-modal {
  position: fixed;
  inset: 0;
  z-index: 4200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.admin-login-modal.open {
  display: flex;
}

.admin-login-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 1, 7, 0.78);
  backdrop-filter: blur(12px);
}

.admin-login-panel {
  position: relative;
  width: min(420px, calc(100vw - 44px));
  max-height: calc(100dvh - 44px);
  overflow-y: auto;
  border: 1px solid rgba(192, 132, 252, 0.44);
  border-radius: 22px;
  background:
    radial-gradient(circle at 82% 0%, rgba(192, 132, 252, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(24, 13, 45, 0.98), rgba(10, 4, 22, 0.98));
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.48),
    0 0 34px rgba(168, 85, 247, 0.18);
  padding: 26px 22px 22px;
}

@media (max-width: 560px) {
  .admin-login-modal {
    padding: 14px;
  }

  .admin-login-panel {
    width: min(420px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
    padding: 24px 18px 20px;
  }
}

.admin-login-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(192, 132, 252, 0.36);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(243, 232, 255, 0.9);
  font-size: 24px;
  line-height: 1;
}

.admin-login-kicker {
  color: var(--accent-neon);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-shadow: var(--lux-neon-text);
}

.admin-login-panel h2 {
  margin: 10px 42px 10px 0;
  color: #fff;
  font-size: 28px;
  line-height: 1.08;
}

.admin-login-panel p {
  margin: 0 0 18px;
  color: rgba(223, 190, 255, 0.86);
  font-size: 14px;
  line-height: 1.45;
}

.admin-login-field {
  display: grid;
  gap: 8px;
}

.admin-login-field span {
  color: rgba(223, 190, 255, 0.78);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-login-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(192, 132, 252, 0.38);
  border-radius: 14px;
  background: rgba(6, 10, 24, 0.76);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 700;
  outline: none;
  padding: 0 14px;
}

.admin-login-field input:focus {
  border-color: rgba(192, 132, 252, 0.78);
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.14), var(--lux-neon-box);
}

.admin-login-error {
  display: block;
  min-height: 18px;
  margin-top: 8px;
  color: #ff77a5;
  font-size: 12px;
  font-weight: 700;
}

.admin-login-submit {
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  border: 1px solid rgba(255, 159, 208, 0.62);
  border-radius: 14px;
  background: linear-gradient(135deg, #8b35ee, #f450b6);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--lux-neon-box);
}

.admin-login-submit:disabled {
  opacity: 0.62;
}

.user-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
}

.user-auth-tabs button {
  min-height: 40px;
  border: 1px solid rgba(192, 132, 252, 0.34);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  color: rgba(223, 190, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
}

.user-auth-tabs button.active {
  border-color: rgba(192, 132, 252, 0.72);
  background:
    radial-gradient(circle at 50% 0%, rgba(192, 132, 252, 0.24), transparent 58%),
    rgba(82, 40, 138, 0.34);
  color: #fff;
  box-shadow: var(--lux-neon-box);
  text-shadow: var(--lux-neon-text);
}

.user-auth-name-field[hidden] {
  display: none;
}

#user-auth-form[hidden],
.user-auth-verification[hidden],
.user-auth-reset[hidden] {
  display: none;
}

.user-auth-verification,
.user-auth-reset {
  display: grid;
  gap: 10px;
}

.user-auth-verification strong,
.user-auth-reset strong {
  overflow-wrap: anywhere;
  color: #fff;
  font-size: 15px;
}

.user-auth-verification span,
.user-auth-reset span {
  color: rgba(223, 190, 255, 0.84);
  font-size: 13px;
  line-height: 1.5;
}

.user-auth-secondary {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: rgba(223, 190, 255, 0.84);
  font-weight: 700;
}

.user-auth-forgot {
  width: fit-content;
  min-height: 32px;
  margin: -2px 0 0 auto;
  padding: 0;
  font-size: 12px;
}

.user-auth-reset-success {
  text-align: center;
}

/* One-time consents: 18+ and the user agreement (registration and the consent dialog). */
.user-auth-consents {
  display: grid;
  gap: 8px;
  margin: 2px 0 4px;
}

.user-auth-consents[hidden] {
  display: none;
}

.user-auth-check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: rgba(244, 240, 251, 0.86);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.user-auth-check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: #a855f7;
  cursor: pointer;
}

.user-auth-check a {
  color: #d8b4fe;
  text-decoration: underline;
  text-underline-offset: 2px;
}

body.theme-light .user-auth-check {
  color: #4a2340;
}

body.theme-light .user-auth-check a {
  color: #c2185b;
}

body.theme-light .admin-login-backdrop {
  background: rgba(48, 20, 32, 0.34);
}

body.theme-light .admin-login-panel {
  background:
    radial-gradient(circle at 82% 0%, rgba(255, 79, 163, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(255, 246, 239, 0.98), rgba(244, 221, 211, 0.96));
  border-color: rgba(255, 92, 166, 0.32);
  box-shadow: 0 22px 62px rgba(154, 79, 103, 0.24);
}

body.theme-light .admin-login-close {
  background: rgba(255, 231, 221, 0.78);
  border-color: rgba(255, 74, 155, 0.35);
  color: #b43367;
}

body.theme-light .admin-login-kicker,
body.theme-light .admin-login-panel h2 {
  color: #8a3156;
}

body.theme-light .admin-login-panel p,
body.theme-light .admin-login-field span {
  color: #9e4967;
}

body.theme-light .admin-login-field input {
  background: rgba(255, 249, 253, 0.78);
  border-color: rgba(197, 55, 107, 0.28);
  color: #5b2a36;
}

body.theme-light .user-auth-tabs button {
  background: rgba(255, 249, 253, 0.64);
  border-color: rgba(197, 55, 107, 0.25);
  color: #9a5870;
}

body.theme-light .user-auth-tabs button.active {
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(255, 74, 155, 0.52);
  color: #8a3156;
  box-shadow:
    0 10px 22px rgba(255, 83, 157, 0.18),
    0 0 22px rgba(255, 83, 157, 0.16);
  text-shadow: none;
}

body.theme-light .admin-login-submit {
  background: linear-gradient(135deg, #ff7fbd, #b74577);
  box-shadow:
    0 12px 28px rgba(255, 83, 157, 0.2),
    0 0 24px rgba(255, 83, 157, 0.18);
}

body.theme-light .user-auth-verification strong,
body.theme-light .user-auth-verification span,
body.theme-light .user-auth-reset strong,
body.theme-light .user-auth-reset span,
body.theme-light .user-auth-secondary {
  color: #8a3156;
}

.media-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 4100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.media-viewer-modal.open {
  display: flex;
}

.media-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 1, 7, 0.78);
  backdrop-filter: blur(12px);
}

.media-viewer-panel {
  position: relative;
  width: min(520px, 100%);
  max-height: min(88vh, 820px);
  overflow: hidden;
  border: 1px solid rgba(192, 132, 252, 0.44);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(192, 132, 252, 0.18), transparent 42%),
    rgba(12, 7, 26, 0.96);
  box-shadow:
    0 0 34px rgba(168, 85, 247, 0.24),
    0 24px 80px rgba(0, 0, 0, 0.52);
}

.media-viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(8, 3, 18, 0.62);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--lux-neon-box);
  backdrop-filter: blur(10px);
}

.media-viewer-frame {
  width: 100%;
  max-height: calc(88vh - 104px);
  background: rgba(2, 6, 23, 0.9);
}

.media-viewer-frame img,
.media-viewer-frame video {
  width: 100%;
  max-height: calc(88vh - 104px);
  display: block;
  object-fit: contain;
}

.media-viewer-copy {
  display: grid;
  gap: 5px;
  padding: 14px 16px 16px;
}

.media-viewer-copy h3 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.12;
  text-shadow: var(--lux-neon-text);
}

.media-viewer-copy p {
  margin: 0;
  color: rgba(226, 218, 246, 0.74);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}

body.modal-open {
  overflow: hidden;
}

body.theme-light .media-viewer-backdrop {
  background: rgba(48, 20, 32, 0.42);
}

body.theme-light .media-viewer-panel {
  border-color: rgba(255, 91, 168, 0.42);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 91, 168, 0.2), transparent 42%),
    rgba(255, 249, 253, 0.96);
  box-shadow:
    0 0 26px rgba(255, 91, 168, 0.2),
    0 22px 70px rgba(126, 63, 92, 0.26);
}

body.theme-light .media-viewer-close {
  border-color: rgba(255, 91, 168, 0.32);
  background: rgba(255, 247, 252, 0.76);
  color: #8c3159;
}

body.theme-light .media-viewer-copy h3 {
  color: #2a1530;
}

body.theme-light .media-viewer-copy p {
  color: #8c5a77;
}

/* Ambient Cyberpunk Glow Orbs */
.glow-bg {
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(147, 51, 234, 0.45) 0%, rgba(0, 0, 0, 0) 70%);
  filter: blur(60px);
  z-index: -1;
  pointer-events: none;
}

.glow-bg-secondary {
  position: fixed;
  bottom: 80px;
  right: -60px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.3) 0%, rgba(0, 0, 0, 0) 70%);
  filter: blur(50px);
  z-index: -1;
  pointer-events: none;
}

.app-container {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, rgba(5, 3, 14, 0.2), rgba(5, 3, 14, 0.46));
}

body.theme-light .app-container {
  background:
    radial-gradient(circle at 80% 12%, rgba(255, 74, 158, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(255, 247, 239, 0.86), rgba(255, 238, 226, 0.42));
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 86px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 22px 14px;
  background: rgba(12, 7, 26, 0.7);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
}

.catalog-mode .header {
  background: rgba(8, 4, 18, 0.42);
  border-bottom: 1px solid rgba(168, 85, 247, 0.16);
  padding: 22px 20px 12px;
}

.logo {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-neon) 60%, var(--accent-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(192, 132, 252, 0.5));
}

.catalog-mode .logo {
  font-size: 30px;
  letter-spacing: 8px;
  -webkit-text-fill-color: #fff;
  color: #fff;
  text-shadow: 0 0 14px rgba(192, 132, 252, 0.85);
}

.tagline {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  display: block;
  font-weight: 700;
}

.catalog-mode .tagline {
  color: rgba(243, 232, 255, 0.74);
  letter-spacing: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-auth-button {
  min-height: 38px;
  max-width: 150px;
  padding: 7px 12px;
  border: 1px solid rgba(192, 132, 252, 0.5);
  border-radius: 8px;
  background: rgba(30, 16, 58, 0.78);
  color: #f8edff;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--lux-neon-box);
}

.header-auth-button:focus-visible {
  outline: 2px solid #d8b4fe;
  outline-offset: 2px;
}

body.theme-light .header-auth-button {
  border-color: rgba(255, 91, 168, 0.5);
  background: rgba(255, 249, 253, 0.82);
  color: #8c3159;
}

@media (max-width: 560px) {
  .header {
    align-items: flex-start;
    gap: 10px;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .header-auth-button {
    max-width: 128px;
    min-height: 36px;
    padding-inline: 9px;
  }
}

.btn-premium {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(147, 51, 234, 0.6);
  transition: transform 0.2s;
}

.btn-premium:active {
  transform: scale(0.96);
}

.btn-premium[data-subscription="general"] {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(192, 132, 252, 0.36);
}

.btn-premium[data-subscription="basic"] {
  background: linear-gradient(135deg, #4c1d95, #2563eb);
}

.btn-premium[data-subscription="premium"] {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
}

.btn-notification {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-admin-crown {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(192, 132, 252, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, rgba(192, 132, 252, 0.16), transparent 48%),
    rgba(12, 7, 26, 0.62);
  color: #f6d6ff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--lux-neon-box);
  filter: var(--lux-neon-icon);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-admin-crown:active {
  transform: scale(0.96);
}

body.theme-light .btn-admin-crown {
  border-color: rgba(255, 91, 168, 0.48);
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 91, 168, 0.2), transparent 48%),
    rgba(255, 249, 253, 0.72);
  color: #8c3159;
}

.home-view,
.catalog-view,
.npc-view,
.story-view {
  padding: 18px;
}

.catalog-mode-switch {
  width: auto;
  margin: 0 -18px 8px;
  overflow: visible;
}

.catalog-mode-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  min-width: 14px;
  height: 14px;
  flex: 0 0 14px;
  font-size: 14px;
  line-height: 1;
  color: currentColor;
}

.catalog-mode-icon svg {
  display: block;
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

.home-section {
  margin-top: 26px;
}

.home-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.home-section-head .section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.15;
}

.home-see-all {
  border: 0;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.home-section-note {
  margin: -4px 0 10px;
  color: rgba(226, 218, 246, 0.72);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}

.home-page-note {
  margin: 18px 40px 8px;
  padding: 10px 0 10px 14px;
  border-left: 2px solid rgba(192, 132, 252, 0.72);
  color: rgba(226, 218, 246, 0.72);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.35;
}

.home-character-row,
.home-video-row,
.home-photo-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.home-character-row::-webkit-scrollbar,
.home-video-row::-webkit-scrollbar,
.home-photo-row::-webkit-scrollbar {
  display: none;
}

.home-character-card,
.home-video-card,
.home-photo-card,
.home-placeholder-card {
  position: relative;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 82px;
  background: rgba(8, 16, 34, 0.72);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  padding: 14px;
  box-shadow:
    0 0 0 1px rgba(238, 221, 255, 0.06),
    0 12px 28px rgba(0, 0, 0, 0.24);
}

.home-character-card::after,
.home-video-card::after,
.home-photo-card::after,
.home-placeholder-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 8% 12%, rgba(192, 132, 252, 0.18), transparent 32%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent 52%);
  pointer-events: none;
}

.home-rank,
.home-card-stat {
  position: relative;
  z-index: 2;
}

.home-rank {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(192, 132, 252, 0.48);
  border-radius: 50%;
  background: rgba(192, 132, 252, 0.12);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-shadow: var(--lux-neon-text);
  box-shadow: var(--lux-neon-box);
}

.home-character-copy {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 5px;
}

.home-character-copy strong {
  font-size: 15px;
  line-height: 1.15;
  font-weight: 600;
  text-transform: none;
}

.home-character-copy span {
  color: rgba(226, 218, 246, 0.78);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
}

.home-character-copy small {
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid rgba(192, 132, 252, 0.36);
  border-radius: 999px;
  background: rgba(8, 16, 34, 0.66);
  color: rgba(243, 232, 255, 0.9);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
}

.home-character-card {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
}

.home-card-stat {
  align-self: start;
  color: #f8d7ff;
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
  text-shadow: var(--lux-neon-text);
  white-space: nowrap;
}

.home-user-list {
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(8, 16, 34, 0.58);
}

.home-author-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0 0 12px;
  padding: 0 14px;
  border: 1px solid rgba(192, 132, 252, 0.32);
  border-radius: 8px;
  background: rgba(10, 6, 24, 0.7);
  color: rgba(216, 180, 254, 0.9);
}

.home-author-search[hidden] {
  display: none;
}

.home-author-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent !important;
  color: var(--text-main);
  color-scheme: dark;
  font: inherit;
}

.home-collection-author-search {
  margin-top: 2px;
}

.home-author-search input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.home-user-row {
  display: grid;
  grid-template-columns: 34px 48px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 0;
  border-right: 0;
  border-top: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.home-user-row:last-child {
  border-bottom: 0;
}

.home-author-row {
  cursor: pointer;
}

.home-author-row:hover {
  background: rgba(192, 132, 252, 0.08);
}

.home-user-row b,
.home-user-avatar {
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(192, 132, 252, 0.44);
  font-size: 13px;
  font-weight: 700;
  text-shadow: var(--lux-neon-text);
}

.home-user-row b {
  width: 34px;
  height: 34px;
}

.home-user-row img,
.home-user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.home-user-row strong,
.home-user-row span {
  display: block;
}

.home-user-row span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.home-user-row em {
  font-style: normal;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 600;
  text-shadow: var(--lux-neon-text);
}

/* Author level («ур. 3», app.js authorLevelBadge). */
.home-user-row em.author-level-badge {
  padding: 4px 10px;
  border: 1px solid rgba(216, 180, 254, 0.45);
  border-radius: 999px;
  background: rgba(88, 28, 135, 0.35);
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.author-panel {
  display: grid;
  gap: 18px;
}

.author-create-button {
  align-self: center;
  white-space: nowrap;
}

.author-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(10, 6, 24, 0.72);
}

.author-profile-card img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.author-profile-card div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.author-profile-card strong,
.author-profile-card span,
.author-profile-card small {
  overflow-wrap: anywhere;
}

.author-profile-card strong {
  color: #fff;
  font-size: 1rem;
}

.author-profile-card span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.92rem;
}

.author-profile-card small {
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.82rem;
}

.author-profile-card .author-character-count {
  width: fit-content;
  margin-top: 5px;
  padding-top: 6px;
  border-top: 1px solid rgba(192, 132, 252, 0.22);
  color: var(--accent-neon);
  font-weight: 700;
}

/* Earned achievements on the profile strip: newest first, 10 shown, the rest behind «…». */
.author-profile-card .author-achievements {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  max-width: 50%;
}

.author-profile-card .author-achievements[hidden] {
  display: none;
}

.author-achievement {
  --badge-color: #a855f7;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--badge-color);
  box-shadow: 0 0 10px color-mix(in srgb, var(--badge-color) 45%, transparent), inset 0 0 8px color-mix(in srgb, var(--badge-color) 25%, transparent);
}

.author-achievement.is-author {
  --badge-color: #db2777;
}

.author-achievement.is-halloween {
  --badge-color: #ea580c;
}

.author-achievement svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--badge-color);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.author-achievements:not(.is-open) .author-achievement[data-extra] {
  display: none;
}

.author-achievements-more {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(192, 132, 252, 0.4);
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-neon);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 640px) {
  .author-profile-card {
    flex-wrap: wrap;
  }

  .author-profile-card .author-achievements {
    justify-content: flex-start;
    max-width: 100%;
    margin-left: 0;
    width: 100%;
  }
}

.author-character-grid {
  width: 100%;
}

.sheet-identity .sheet-author-line {
  margin-bottom: 4px;
  color: var(--accent-neon);
  font-weight: 600;
}

body.theme-light .author-profile-card {
  background: rgba(255, 247, 252, 0.44);
  border-color: rgba(168, 85, 247, 0.26);
}

body.theme-light .author-profile-card strong {
  color: #251334;
}

body.theme-light .author-profile-card span,
body.theme-light .author-profile-card small {
  color: #745684;
}

.author-empty-card {
  grid-column: 1 / -1;
}

.home-video-card,
.home-photo-card,
.home-placeholder-card {
  display: grid;
  gap: 7px;
  text-decoration: none;
}

.home-video-card strong,
.home-video-card span,
.home-video-card small,
.home-photo-card strong,
.home-photo-card span,
.home-photo-card small,
.home-placeholder-card b,
.home-placeholder-card span {
  position: relative;
  z-index: 2;
}

.home-video-card strong,
.home-photo-card strong,
.home-placeholder-card b {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.home-video-card span,
.home-photo-card span,
.home-placeholder-card span {
  color: rgba(226, 218, 246, 0.74);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.home-video-card small,
.home-photo-card small {
  width: fit-content;
  color: rgba(248, 215, 255, 0.92);
  font-size: 11px;
  font-weight: 500;
  text-shadow: var(--lux-neon-text);
}

body.theme-light .home-section-head .section-title {
  color: #24142d;
  text-shadow: 0 0 12px rgba(168, 85, 247, 0.18);
}

body.theme-light .home-see-all {
  color: #6c3f8f;
}

body.theme-light .home-character-card,
body.theme-light .home-video-card,
body.theme-light .home-photo-card,
body.theme-light .home-placeholder-card,
body.theme-light .home-user-list {
  background: rgba(255, 247, 252, 0.78);
  border-color: rgba(168, 85, 247, 0.34);
  box-shadow: 0 14px 28px rgba(129, 72, 154, 0.16);
}

body.theme-light .home-section-note,
body.theme-light .home-page-note,
body.theme-light .home-character-copy span,
body.theme-light .home-video-card span,
body.theme-light .home-photo-card span,
body.theme-light .home-placeholder-card span {
  color: #745684;
}

body.theme-light .home-user-row {
  border-bottom-color: rgba(99, 45, 129, 0.1);
}

body.theme-light .home-author-search {
  background: rgba(255, 247, 252, 0.38);
  border-color: rgba(168, 85, 247, 0.34);
  color: #6c3f8f;
}

body.theme-light .home-author-search input {
  background: transparent !important;
  color: #251334;
  color-scheme: light;
}

body.theme-light .home-author-search input::placeholder {
  color: #8d6d9c;
}

body.theme-light .home-author-row:hover {
  background: rgba(168, 85, 247, 0.1);
}

body.theme-light .home-user-row span {
  color: #745684;
}

body.theme-light .home-user-row em,
body.theme-light .home-user-row strong {
  color: #251334;
}

.admin-view {
  padding: 16px;
}

.admin-hero {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(147, 51, 234, 0.18), rgba(6, 182, 212, 0.05)),
    var(--card-bg);
  padding: 18px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: start;
  box-shadow: 0 0 26px rgba(147, 51, 234, 0.18);
}

.admin-back {
  width: 42px;
  height: 42px;
}

.admin-kicker {
  color: var(--accent-neon);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.admin-hero h2 {
  font-size: 26px;
  line-height: 1.05;
  margin-bottom: 6px;
}

.admin-hero span {
  color: rgba(243, 232, 255, 0.72);
  font-size: 13px;
}

.admin-top-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
}

.admin-top-actions button {
  min-height: 40px;
  border: 1px solid rgba(192, 132, 252, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-weight: 800;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.admin-stat-card {
  min-height: 94px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at top right, rgba(192, 132, 252, 0.18), transparent 45%),
    var(--card-bg);
  padding: 14px;
}

.admin-stat-card span {
  display: block;
  min-height: 32px;
  color: rgba(243, 232, 255, 0.68);
  font-size: 12px;
  font-weight: 700;
}

.admin-stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 0 14px rgba(192, 132, 252, 0.55);
}

.admin-stat-clickable {
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.admin-stat-clickable:hover,
.admin-stat-clickable:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(192, 132, 252, 0.72);
  box-shadow: 0 0 24px rgba(168, 85, 247, 0.26);
  outline: none;
}

.admin-db-panel {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 82% 0%, rgba(192, 132, 252, 0.16), transparent 36%),
    var(--card-bg);
  padding: 18px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

.admin-db-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.admin-db-header h2 {
  margin: 0;
  color: var(--text-main);
  font-size: 24px;
  letter-spacing: 0.04em;
}

.admin-db-header span {
  color: var(--text-muted);
}

.admin-db-list {
  display: grid;
  gap: 12px;
}

.admin-memory-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-memory-overview article,
.admin-memory-card,
.admin-memory-model {
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: var(--radius-md);
  background: rgba(8, 16, 34, 0.68);
}

.admin-memory-overview article {
  padding: 12px;
  display: grid;
  gap: 4px;
}

.admin-memory-overview span,
.admin-memory-card span,
.admin-memory-card small,
.admin-memory-model {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-memory-overview strong {
  color: var(--text-main);
  font-size: 22px;
}

.admin-memory-title {
  margin: 12px 0 0;
  color: var(--text-main);
  font-size: 15px;
}

.admin-memory-card {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.admin-memory-card strong {
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.35;
}

.admin-memory-card p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.admin-memory-metrics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-memory-metrics small {
  padding: 5px 8px;
  border: 1px solid rgba(192, 132, 252, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-memory-model {
  padding: 10px 12px;
}

.admin-db-list.admin-db-catalog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.admin-db-card,
.admin-user-card,
.admin-db-empty,
.admin-db-loading {
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: var(--radius-md);
  background: rgba(8, 16, 34, 0.68);
}

.admin-db-card {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.admin-db-catalog-card {
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
  padding: 8px;
}

.admin-db-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid rgba(192, 132, 252, 0.34);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.24);
}

.admin-db-media {
  width: 76px;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(192, 132, 252, 0.36);
  background: rgba(0, 0, 0, 0.24);
}

.admin-db-catalog-card .admin-db-media {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border: 0;
  border-radius: inherit;
}

.admin-db-cover-text {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  display: grid;
  gap: 2px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.92);
}

.admin-db-cover-text strong {
  color: #fff;
  font-size: clamp(11px, 3vw, 15px);
  font-weight: 800;
  line-height: 1.05;
  text-transform: uppercase;
}

.admin-db-cover-text small {
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(8px, 2.2vw, 10px);
  font-weight: 800;
  line-height: 1.15;
}

.admin-db-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 800;
}

.admin-db-info strong {
  display: block;
  color: var(--text-main);
  font-size: 17px;
}

.admin-db-info span,
.admin-db-info small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  line-height: 1.35;
}

.admin-db-meta {
  min-height: 28px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.25;
}

.admin-db-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.admin-db-actions button,
.admin-plan-select {
  min-height: 42px;
  border: 1px solid rgba(192, 132, 252, 0.34);
  border-radius: 14px;
  background: rgba(126, 45, 226, 0.18);
  color: var(--text-main);
  font-weight: 800;
}

.admin-db-catalog-card .admin-db-actions {
  grid-column: auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.admin-db-catalog-card .admin-db-actions button {
  min-height: 30px;
  border-radius: 10px;
  padding: 0 3px;
  font-size: 8px;
}

.admin-db-actions .admin-db-danger {
  border-color: rgba(255, 80, 130, 0.58);
  color: #ff77a5;
}

.admin-user-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 190px);
  gap: 12px;
  align-items: start;
  padding: 14px;
  min-width: 0;
  overflow: hidden;
}

.admin-referral-card {
  grid-template-columns: minmax(0, 1fr);
}

.admin-referral-card > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-referral-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.admin-referral-list li {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-left: 2px solid var(--admin-action, #a855f7);
  background: var(--admin-panel-soft, rgba(255, 255, 255, 0.04));
  border-radius: 6px;
  overflow-wrap: anywhere;
}

.admin-referral-list small {
  color: var(--admin-dim, rgba(255, 255, 255, 0.6));
  font-size: 12px;
}

.admin-user-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(192, 132, 252, 0.24);
  border-radius: var(--radius-md);
  background: rgba(8, 16, 34, 0.68);
  padding: 12px;
}

.admin-user-search label {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-user-search input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(192, 132, 252, 0.34);
  border-radius: 14px;
  background: rgba(6, 10, 24, 0.72);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 800;
  outline: none;
  padding: 0 12px;
}

.admin-user-search input:focus {
  border-color: rgba(192, 132, 252, 0.72);
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.14);
}

.admin-user-search small {
  color: var(--accent-neon);
  font-weight: 800;
}

.admin-user-card-banned {
  border-color: rgba(255, 80, 130, 0.62);
}

.admin-user-card strong {
  color: var(--text-main);
}

.admin-user-card .admin-user-identity {
  margin-top: 2px;
  font-size: 12px;
}

.admin-user-card span {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  line-height: 1.35;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.admin-user-meta small {
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--text-muted);
}

.admin-user-note {
  margin-top: 8px;
  font-size: 12px;
}

.admin-media-url {
  max-width: 100%;
  font-size: 11px;
  line-height: 1.25;
  opacity: 0.78;
}

.admin-user-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.admin-user-controls .admin-plan-select {
  grid-column: 1 / -1;
  width: 100%;
}

.admin-user-controls button {
  min-height: 38px;
  border: 1px solid rgba(192, 132, 252, 0.34);
  border-radius: 12px;
  background: rgba(126, 45, 226, 0.18);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 800;
  padding: 0 8px;
  min-width: 0;
}

.admin-db-empty,
.admin-db-loading {
  padding: 18px;
  color: var(--text-muted);
}

@media (max-width: 560px) {
  .admin-db-card {
    grid-template-columns: 64px 1fr;
    padding: 10px;
  }

  .admin-db-media {
    width: 64px;
  }

  .admin-user-card {
    grid-template-columns: 1fr;
  }

  .admin-db-actions {
    grid-template-columns: 1fr;
  }

  .admin-user-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-runtime-grid,
  .admin-plan-grid {
    grid-template-columns: 1fr;
  }

  .admin-db-list.admin-db-catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .admin-db-catalog-card {
    padding: 6px;
  }

  .admin-db-catalog-card .admin-db-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
  }

  .admin-db-catalog-card .admin-db-actions button {
    min-height: 28px;
    border-radius: 9px;
    font-size: 7px;
  }
}

body.theme-light .admin-stat-clickable:hover,
body.theme-light .admin-stat-clickable:focus-visible {
  border-color: rgba(255, 75, 160, 0.65);
  box-shadow: 0 0 24px rgba(255, 75, 160, 0.2);
}

body.theme-light .admin-db-panel,
body.theme-light .admin-db-card,
body.theme-light .admin-user-card,
body.theme-light .admin-user-search,
body.theme-light .admin-db-empty,
body.theme-light .admin-db-loading {
  background: linear-gradient(135deg, rgba(255, 246, 239, 0.95), rgba(245, 218, 207, 0.86));
  border-color: rgba(255, 92, 166, 0.28);
  box-shadow:
    0 14px 38px rgba(115, 62, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

body.theme-light .admin-db-header h2,
body.theme-light .admin-db-info strong,
body.theme-light .admin-user-card strong {
  color: #6f3d34;
  text-shadow: 0 0 12px rgba(255, 92, 169, 0.24);
}

body.theme-light .admin-db-header span,
body.theme-light .admin-db-info span,
body.theme-light .admin-db-info small,
body.theme-light .admin-user-card span,
body.theme-light .admin-user-meta small,
body.theme-light .admin-user-search label,
body.theme-light .admin-db-empty,
body.theme-light .admin-db-loading {
  color: #9a5b68;
}

body.theme-light .admin-user-search input {
  background: rgba(255, 246, 239, 0.82);
  border-color: rgba(255, 92, 169, 0.35);
  color: #7b4050;
}

body.theme-light .admin-db-actions button,
body.theme-light .admin-plan-select {
  background: rgba(233, 196, 184, 0.72);
  border-color: rgba(255, 92, 169, 0.35);
  color: #7b4050;
}

body.theme-light .admin-db-cover {
  border-color: rgba(255, 92, 169, 0.42);
  box-shadow: 0 14px 28px rgba(103, 54, 39, 0.2);
}

body.theme-light .admin-db-cover-text strong,
body.theme-light .admin-db-cover-text small {
  color: #ff62aa;
  text-shadow:
    0 0 9px rgba(255, 92, 169, 0.52),
    0 2px 8px rgba(74, 37, 25, 0.82);
}

body.theme-light .admin-db-meta {
  color: #9a5b68;
}

.admin-control-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.admin-control-card {
  width: 100%;
  min-height: 82px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.26), rgba(12, 7, 26, 0.78));
  color: var(--text-main);
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  text-align: left;
  padding: 14px;
  cursor: pointer;
}

.admin-control-card > span {
  grid-row: 1 / 3;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(147, 51, 234, 0.35);
  color: #fff;
  font-size: 22px;
}

.admin-control-card strong {
  font-size: 16px;
  font-weight: 800;
}

.admin-control-card small {
  color: rgba(243, 232, 255, 0.62);
  font-size: 12px;
  line-height: 1.35;
}

.admin-runtime-panel {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.18), rgba(12, 7, 26, 0.68));
}

.admin-runtime-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.admin-runtime-header h3 {
  margin: 2px 0 0;
  color: var(--text-main);
  font-size: 20px;
}

.admin-runtime-header button,
.admin-plan-card button {
  min-height: 38px;
  border: 1px solid rgba(255, 92, 169, 0.38);
  border-radius: 12px;
  background: rgba(255, 79, 169, 0.2);
  color: var(--text-main);
  font-weight: 800;
}

.admin-runtime-grid,
.admin-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-toggle-row,
.admin-field,
.admin-plan-card {
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
  font-weight: 800;
}

.admin-field,
.admin-plan-card label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-field input,
.admin-field select,
.admin-field textarea,
.admin-plan-card input {
  width: 100%;
  border: 1px solid rgba(192, 132, 252, 0.28);
  border-radius: 10px;
  background: rgba(9, 6, 20, 0.62);
  color: var(--text-main);
  padding: 10px;
  font: inherit;
}

.admin-wide {
  grid-column: 1 / -1;
}

.admin-plan-card {
  display: grid;
  gap: 10px;
}

.admin-plan-card strong {
  color: var(--text-main);
}

.admin-media-view {
  padding-bottom: 120px;
}

.admin-media-top {
  align-items: stretch;
}

.admin-media-uploader {
  min-height: 310px;
}

.admin-media-preview {
  position: relative;
  min-height: 250px;
  overflow: hidden;
}

.admin-media-preview.has-media {
  padding: 0;
}

.admin-media-preview img,
.admin-media-preview video {
  width: 100%;
  height: 100%;
  min-height: 250px;
  display: block;
  object-fit: cover;
}

.admin-media-preview small {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: block;
  padding: 8px 10px;
  border: 1px solid rgba(192, 132, 252, 0.28);
  border-radius: 999px;
  background: rgba(8, 3, 18, 0.62);
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

body.theme-light .admin-media-preview small {
  border-color: rgba(255, 91, 168, 0.36);
  background: rgba(255, 247, 252, 0.7);
  color: #8c3159;
}

.admin-log-list {
  display: grid;
  gap: 8px;
}

.admin-log-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(192, 132, 252, 0.18);
  border-radius: 10px;
  color: var(--text-main);
}

.admin-log-row small {
  grid-column: 2;
  color: var(--text-muted);
}

.admin-health-grid {
  display: grid;
  gap: 10px;
}

.admin-health-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}

.admin-health-modal.open {
  display: block;
}

.admin-health-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 3, 14, 0.72);
  backdrop-filter: blur(10px);
}

.admin-health-modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(92vw, 520px);
  max-height: min(86vh, 760px);
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: 16px;
  border: 1px solid rgba(192, 132, 252, 0.32);
  border-radius: 18px;
  background: rgba(20, 10, 38, 0.96);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
}

.admin-health-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-health-modal-actions button {
  min-height: 36px;
  border: 1px solid rgba(192, 132, 252, 0.36);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  font-weight: 800;
}

#admin-health-close {
  width: 38px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.admin-health-card,
.admin-health-backup,
.admin-health-count {
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-health-card {
  min-height: 50px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--text-main);
  font-weight: 800;
}

.admin-health-card small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.admin-health-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-health-pill.is-ok {
  color: #c7ffd8;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(34, 197, 94, 0.36);
}

.admin-health-pill.is-bad {
  color: #ffd1dc;
  background: rgba(244, 63, 94, 0.18);
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.admin-health-backup {
  padding: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.admin-health-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-health-actions button {
  min-height: 42px;
  border: 1px solid rgba(168, 85, 247, 0.48);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.26), rgba(236, 72, 153, 0.18));
  color: var(--text-main);
  font-weight: 950;
}

.admin-health-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-health-count {
  padding: 10px;
}

.admin-health-count span,
.admin-health-count strong {
  display: block;
}

.admin-health-count span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.admin-health-count strong {
  margin-top: 4px;
  color: var(--text-main);
  font-size: 20px;
}

.admin-health-events {
  display: grid;
  gap: 8px;
}

/* «Проверить ИИ»: one row per provider gateway and model. */
.admin-ai-report {
  display: grid;
  gap: 6px;
  grid-column: 1 / -1;
}

.admin-ai-report:empty {
  display: none;
}

.admin-ai-report h4 {
  margin: 4px 0;
  color: var(--text-main);
  font-size: 14px;
}

.admin-ai-report h4 small {
  color: var(--text-muted);
  font-weight: 600;
}

.admin-ai-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-ai-row strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.admin-ai-row small,
.admin-ai-row em {
  color: var(--text-muted);
  font-size: 12px;
  font-style: normal;
  overflow-wrap: anywhere;
}

.admin-ai-row em {
  grid-column: 1 / -1;
}

.admin-ai-status {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-ai-row.is-ok .admin-ai-status {
  background: rgba(74, 222, 128, 0.16);
  color: #6ee7a0;
}

.admin-ai-row.is-error .admin-ai-status {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
}

.admin-ai-row.is-no_key .admin-ai-status {
  background: rgba(250, 204, 21, 0.16);
  color: #fde68a;
}

.admin-health-events h4 {
  margin: 4px 0 0;
  color: var(--text-main);
  font-size: 14px;
}

.admin-health-event {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-health-event strong {
  color: var(--text-main);
  font-size: 12px;
}

.admin-health-event span,
.admin-health-event small {
  color: var(--text-muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

body.theme-light .admin-hero span,
body.theme-light .admin-stat-card span,
body.theme-light .admin-control-card small {
  color: rgba(43, 20, 32, 0.66);
}

body.theme-light .admin-stat-card strong {
  color: #2b1420;
}

body.theme-light .admin-runtime-panel,
body.theme-light .admin-toggle-row,
body.theme-light .admin-field,
body.theme-light .admin-plan-card,
body.theme-light .admin-log-row,
body.theme-light .admin-health-card,
body.theme-light .admin-health-backup,
body.theme-light .admin-health-count {
  background: rgba(255, 246, 239, 0.72);
  border-color: rgba(255, 92, 169, 0.28);
}

/* Sub Nav */
.sub-nav {
  display: flex;
  justify-content: space-around;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.theme-light .sub-nav {
  background: rgba(255, 231, 221, 0.84);
  border-bottom-color: rgba(255, 92, 166, 0.18);
  box-shadow: 0 14px 30px rgba(154, 79, 103, 0.12);
}

.sub-nav-item {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  appearance: none;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 14px;
  transition: all 0.2s;
  text-align: center;
}

.sub-nav-item.active {
  color: #fff;
  background: transparent;
  text-shadow: var(--lux-neon-text);
  filter: var(--lux-neon-icon);
  box-shadow: var(--lux-neon-box);
  border: 1px solid var(--card-border);
}

body.theme-light .sub-nav-item {
  background: rgba(190, 143, 160, 0.28);
  border-color: rgba(255, 92, 166, 0.22);
  color: #9b4967;
  text-shadow: 0 0 8px rgba(255, 91, 168, 0.12);
}

body.theme-light .sub-nav-item.active {
  color: #8c3159;
  background: rgba(255, 249, 253, 0.52);
  border-color: rgba(255, 91, 168, 0.72);
  text-shadow: var(--lux-neon-text);
  filter: var(--lux-neon-icon);
  box-shadow: var(--lux-neon-box);
}

.empty-state-panel {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text-muted);
  padding: 18px;
}

.saved-header-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.saved-header-row .section-title {
  margin-bottom: 6px;
}

#saved-slots-count {
  color: var(--text-muted);
  font-size: 15px;
}

.saved-create-btn {
  border: 1px solid var(--accent-purple);
  border-radius: 8px;
  background: rgba(82, 22, 140, 0.22);
  color: #ead8ff;
  min-height: 42px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.saved-characters-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.saved-character-card {
  position: relative;
  min-height: 220px;
  border: 1px solid rgba(168, 85, 247, 0.55);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(8, 8, 24, 0.82);
  cursor: pointer;
  box-shadow: 0 0 18px rgba(124, 58, 237, 0.18);
}

.saved-character-card img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
  display: block;
}

.saved-character-card::after {
  content: "";
  position: absolute;
  inset: 35% 0 0;
  background: linear-gradient(180deg, transparent, rgba(4, 2, 12, 0.94));
  pointer-events: none;
}

.saved-character-body {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
}

.saved-character-body strong {
  display: block;
  color: #fff;
  font-size: 17px;
  line-height: 1.05;
  margin-bottom: 5px;
}

.saved-character-body span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.25;
}

.saved-character-meta {
  margin-top: 8px;
  color: #c7b8f8;
  font-size: 10px;
}

.saved-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(216, 180, 254, 0.55);
  background: rgba(20, 8, 34, 0.78);
  color: #f1ddff;
  cursor: pointer;
  font-size: 18px;
}

.storage-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
}

.storage-icon {
  color: var(--accent-neon);
  font-size: 32px;
  text-shadow: var(--neon-glow);
}

.storage-panel b,
.storage-panel span {
  display: block;
}

.storage-panel span {
  color: var(--text-muted);
  margin-top: 5px;
  font-size: 12px;
}

.slot-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.slot-detail-back {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.slot-detail-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(168, 85, 247, 0.45);
  border-radius: 10px;
  min-height: 280px;
  background: rgba(8, 8, 24, 0.82);
}

.slot-detail-hero > img {
  width: 100%;
  height: 320px;
  object-fit: cover;
  display: block;
}

.slot-detail-avatar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(216, 180, 254, 0.45);
  border-radius: 8px;
  background: rgba(9, 6, 24, 0.78);
  backdrop-filter: blur(10px);
}

.slot-detail-avatar img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.slot-detail-avatar span,
.slot-detail-avatar b {
  display: block;
}

.slot-detail-avatar span {
  color: var(--text-muted);
  font-size: 11px;
}

.slot-detail-avatar b {
  color: #fff;
  font-size: 15px;
}

.slot-detail-block {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card-bg);
}

.slot-detail-block label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 800;
}

.slot-detail-block textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid rgba(168, 85, 247, 0.45);
  border-radius: 8px;
  background: rgba(7, 5, 18, 0.72);
  color: var(--text-main);
  padding: 12px;
  font: inherit;
  line-height: 1.45;
  outline: none;
}

.slot-detail-block textarea:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.16);
}

.slot-detail-block small {
  display: block;
  margin-top: 6px;
  text-align: right;
  color: var(--text-muted);
  font-size: 11px;
}

.slot-detail-last-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.slot-detail-actions {
  position: sticky;
  bottom: 74px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 0 0;
  background: linear-gradient(180deg, transparent, var(--bg-main) 28%);
}

.slot-detail-select,
.slot-detail-clear {
  min-height: 46px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.slot-detail-select {
  border: 1px solid var(--accent-purple);
  background: rgba(82, 22, 140, 0.48);
  color: #fff;
}

.slot-detail-clear {
  border: 1px solid rgba(244, 114, 182, 0.55);
  background: rgba(88, 20, 52, 0.28);
  color: #ffd8e9;
}

@media (min-width: 620px) {
  .saved-characters-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.cabinet-saved-panel.section-container,
.cabinet-saved-detail-panel.section-container,
.cabinet-npc-panel.section-container {
  display: block;
}

.cabinet-npc-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.cabinet-npc-card {
  width: 100%;
}

.saved-characters-grid .empty-state-panel {
  grid-column: 1 / -1;
}

/* Personalities Carousel */
.personalities-carousel {
  display: flex;
  gap: 12px;
  padding: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.personalities-carousel::-webkit-scrollbar {
  display: none;
}

.personality-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: pointer;
  min-width: 86px;
  width: 86px;
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
}

.avatar-wrapper {
  width: 100%;
  height: 128px;
  border-radius: 14px;
  background: rgba(147, 51, 234, 0.2);
  border: 2px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  transition: all 0.25s ease;
  overflow: hidden;
  position: relative;
}

.avatar-wrapper::after {
  content: "";
  position: absolute;
  inset: 40% 0 0;
  background: linear-gradient(180deg, transparent, rgba(5, 3, 15, 0.88));
  pointer-events: none;
}

.avatar-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-empty-plus {
  color: var(--accent-neon);
  font-size: 36px;
  line-height: 1;
  text-shadow: 0 0 14px var(--accent-neon);
  z-index: 1;
}

.personality-card.active .avatar-wrapper {
  border-color: var(--accent-neon);
  box-shadow: 0 0 18px var(--accent-neon);
  transform: scale(1.05);
}

.personality-name {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-align: left;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-levels {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 31px;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  pointer-events: none;
}

.avatar-levels span {
  min-width: 0;
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(8, 5, 20, 0.66);
  color: rgba(255, 255, 255, 0.92);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  text-align: left;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent-neon);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-neon);
}

.create-card .avatar-wrapper {
  border-style: dashed;
  border-color: var(--accent-purple);
}

.create-text {
  margin-top: 8px;
  font-size: 10px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
}

/* Section Titles */
.section-container, .gameplay-section {
  padding: 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #fff;

}

.avatar-meaning-note {
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 2px solid rgba(192, 132, 252, 0.72);
  color: rgba(244, 232, 255, 0.82);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  letter-spacing: 0;
  text-shadow: 0 0 14px rgba(192, 132, 252, 0.28);
}

.section-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Avatar Preview Card */
.avatar-preview-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
}

.preview-image-container {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  background: rgba(147, 51, 234, 0.25);
  border: 2px solid var(--accent-neon);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.5);
  position: relative;
}

.preview-image-container::before {
  content: "+";
  color: var(--accent-neon);
  font-size: 48px;
  line-height: 1;
  text-shadow: 0 0 18px var(--accent-neon);
}

.preview-image-container.has-image::before {
  display: none;
}

.preview-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-image-container img:not([src]) {
  display: none;
}

.romance-status {
  color: var(--accent-neon);
  font-size: 12px;
  font-weight: 800;
  margin: -4px 0 12px;
  text-transform: uppercase;
}

.btn-change-avatar {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: #fff;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 4px 15px rgba(147, 51, 234, 0.5);
  transition: transform 0.2s;
}

.btn-change-avatar:active {
  transform: scale(0.98);
}

.btn-delete-avatar {
  width: calc(100% - 32px);
  margin: 10px 16px 88px;
  border: 1px solid rgba(248, 113, 113, 0.36);
  border-radius: 10px;
  background: rgba(55, 10, 26, 0.35);
  color: rgba(254, 202, 202, 0.88);
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  cursor: pointer;
}

/* Form Inputs Grid */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 560px) {
  .section-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(170px, 34%);
    column-gap: 16px;
    align-items: start;
  }

  .section-container .section-title,
  .section-container .section-subtitle {
    grid-column: 1 / -1;
  }

  .section-container .avatar-preview-card {
    grid-column: 2;
    grid-row: 3;
    margin-bottom: 0;
  }

  .section-container .settings-grid {
    grid-column: 1;
    grid-row: 3;
  }
}

.form-group {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  backdrop-filter: blur(10px);
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-icon {
  font-size: 20px;
  color: var(--accent-neon);
}

.field-content {
  flex: 1;
}

.field-label {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
  font-weight: 700;
  text-transform: uppercase;
}

.form-input {
  background: none;
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
  outline: none;
}

.form-textarea {
  background: none;
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
  min-height: 74px;
  resize: vertical;
  outline: none;
  line-height: 1.35;
}

.form-textarea.compact {
  min-height: 56px;
}

.form-field {
  display: block;
  min-width: 0;
}

body:not(.theme-light) .create-character-view .form-field,
body:not(.theme-light) .create-character-view .form-group,
body:not(.theme-light) .create-character-view .photo-uploader,
body:not(.theme-light) .create-character-view .behavior-panel {
  background:
    linear-gradient(135deg, rgba(8, 18, 36, 0.78), rgba(19, 7, 35, 0.62));
  border: 1px solid rgba(178, 116, 255, 0.24);
  border-radius: 16px;
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 12px 14px;
}

body:not(.theme-light) .create-character-view .form-input,
body:not(.theme-light) .create-character-view .form-textarea,
body:not(.theme-light) .create-character-view .npc-stat-input {
  background: rgba(2, 8, 20, 0.48);
  border: 1px solid rgba(178, 116, 255, 0.16);
  border-radius: 10px;
  color: #f7efff;
  -webkit-text-fill-color: #f7efff;
  caret-color: #bf7cff;
  padding: 10px 12px;
}

body:not(.theme-light) .create-character-view .form-input::placeholder,
body:not(.theme-light) .create-character-view .form-textarea::placeholder {
  color: rgba(214, 193, 255, 0.56);
  -webkit-text-fill-color: rgba(214, 193, 255, 0.56);
}

body:not(.theme-light) .create-character-view .form-input:focus,
body:not(.theme-light) .create-character-view .form-textarea:focus,
body:not(.theme-light) .create-character-view .npc-stat-input:focus {
  border-color: rgba(190, 124, 255, 0.58);
  box-shadow:
    0 0 0 1px rgba(190, 124, 255, 0.16),
    0 0 18px rgba(126, 52, 255, 0.18);
  outline: none;
}

body:not(.theme-light) .create-character-view select.form-input option {
  background: #12091d;
  color: #f7efff;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 0;
}

.admin-wide {
  grid-column: 1 / -1;
}

.create-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.icon-back {
  background: none;
  border: none;
  color: var(--accent-neon);
  font-size: 42px;
  line-height: 1;
  cursor: pointer;
}

.create-top-grid {
  display: grid;
  grid-template-columns: minmax(130px, 0.9fr) minmax(0, 1.6fr);
  gap: 14px;
  margin-bottom: 14px;
  align-items: start;
}

.photo-uploader {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 12px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.photo-preview {
  aspect-ratio: 3 / 4;
  border: 2px dashed var(--accent-purple);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--accent-neon);
  font-weight: 800;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  overflow: hidden;
}

.photo-preview.ratio-square {
  aspect-ratio: 1 / 1;
}

.photo-preview.ratio-portrait {
  aspect-ratio: 3 / 4;
}

.photo-preview.ratio-tall {
  aspect-ratio: 9 / 16;
}

.photo-preview.has-photo {
  border-style: solid;
  box-shadow: 0 0 18px rgba(192, 132, 252, 0.5);
}

.image-ratio-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.ratio-option {
  display: grid;
  place-items: center;
  min-height: 28px;
  border: 1px solid rgba(192, 132, 252, 0.32);
  border-radius: 8px;
  color: rgba(216, 202, 255, 0.74);
  background: rgba(12, 7, 26, 0.48);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.ratio-option.active {
  color: #fff;
  border-color: var(--accent-neon);
  background: rgba(147, 51, 234, 0.34);
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.38);
}

.photo-plus {
  font-size: 54px;
  line-height: 1;
}

.photo-uploader p,
.context-text,
.range-labels {
  color: rgba(216, 202, 255, 0.7);
  font-size: 11px;
}

.photo-uploader p {
  margin-top: 10px;
}

.create-main-fields {
  align-content: start;
}

.create-fields {
  margin-bottom: 14px;
}

.behavior-panel {
  background: rgba(12, 7, 26, 0.45);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.style-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.style-option {
  min-height: 96px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 34px;
  cursor: pointer;
}

.style-option span {
  font-size: 13px;
}

.style-option.active {
  border-color: var(--accent-purple);
  box-shadow: 0 0 18px rgba(147, 51, 234, 0.45);
  color: var(--accent-neon);
}

.admin-submit {
  width: 100%;
  margin-top: 16px;
}

.create-user-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.setting-row,
.npc-stat-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(120px, 2fr) 52px;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: var(--text-main);
}

.setting-row input[type="range"],
.npc-stat-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent-neon);
}

.npc-stat-input {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
}

.story-achievement-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) minmax(160px, 1fr);
  align-items: center;
  gap: 10px;
  margin: 12px 0 16px;
  color: var(--text-main);
  font-weight: 700;
}

.story-achievement-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-neon);
}

.story-picker-title {
  margin: 10px 0 8px;
  color: var(--accent-neon);
  font-weight: 800;
  letter-spacing: 0;
}

.story-npc-dropdown {
  margin-top: 12px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(12, 7, 26, 0.28);
  overflow: hidden;
}

.story-npc-dropdown summary {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  color: var(--text-main);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.story-npc-dropdown summary::-webkit-details-marker {
  display: none;
}

.story-npc-dropdown summary::after {
  content: "⌄";
  color: var(--accent-neon);
  font-size: 18px;
  line-height: 1;
}

.story-npc-dropdown[open] summary::after {
  content: "⌃";
}

.story-npc-dropdown summary b {
  justify-self: end;
  color: var(--text-muted);
  font-size: 12px;
}

.story-npc-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 0 12px 12px;
}

.story-npc-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: center;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(12, 7, 26, 0.32);
  color: var(--text-main);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.story-npc-chip input {
  grid-row: span 2;
  accent-color: var(--accent-neon);
}

.story-npc-chip span {
  font-weight: 800;
}

.story-npc-chip small {
  color: var(--text-muted);
  font-weight: 700;
}

.story-npc-chip.selected {
  border-color: var(--accent-neon);
  background: rgba(147, 51, 234, 0.22);
  box-shadow: 0 0 16px rgba(192, 132, 252, 0.26);
}

.field-label small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.admin-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.story-edit {
  position: absolute;
  z-index: 5;
  right: 12px;
  top: 48px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--accent-neon);
  background: rgba(10, 4, 18, 0.42);
  border: 1px solid rgba(216, 180, 254, 0.75);
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.32);
}

.catalog-edit,
.catalog-delete,
.npc-edit {
  position: absolute;
  z-index: 6;
  right: 12px;
  bottom: 18px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 45% 30%, rgba(255, 255, 255, 0.24), transparent 34%),
    linear-gradient(145deg, rgba(74, 38, 112, 0.94), rgba(18, 8, 34, 0.92));
  border: 1px solid rgba(232, 213, 255, 0.86);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  text-shadow:
    0 0 8px rgba(199, 153, 255, 0.64),
    0 0 18px rgba(168, 85, 247, 0.52);
  box-shadow:
    0 0 0 1px rgba(168, 85, 247, 0.2),
    0 0 14px rgba(199, 153, 255, 0.3),
    0 0 22px rgba(168, 85, 247, 0.54),
    0 10px 20px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
}

.home-media-card .catalog-edit,
.home-character-card .catalog-edit {
  right: 12px;
  bottom: 16px;
  transform: none;
}

.npc-edit {
  right: 54px;
}

.catalog-delete {
  right: 54px;
  font-size: 24px;
  line-height: 1;
}

@media (max-width: 420px) {
  .create-top-grid {
    grid-template-columns: 1fr;
  }

  .style-options {
    grid-template-columns: 1fr;
  }

  .setting-row,
  .npc-stat-row {
    grid-template-columns: 1fr;
  }

  .create-user-actions {
    grid-template-columns: 1fr;
  }
}

/* Sliders & Segmented */
.slider-group, .segmented-group {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  backdrop-filter: blur(10px);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 8px;
  font-weight: 700;
}

.slider-value {
  color: var(--accent-neon);
  font-weight: 800;
}

.custom-slider {
  width: 100%;
  accent-color: var(--accent-neon);
}

.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  padding: 3px;
  border-radius: 10px;
}

.segment-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
}

.segment-btn.active {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  box-shadow: 0 0 10px rgba(147, 51, 234, 0.5);
}

/* Save Button */
.btn-save-settings {
  margin: 16px;
  width: calc(100% - 32px);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(147, 51, 234, 0.6);
}

/* Character Catalog */
.catalog-view {
  padding: 0 clamp(10px, 3vw, 18px) 88px;
}

.catalog-hero {
  padding: 4px 6px 18px;
}

.catalog-logo {
  font-size: 36px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 8px;
  color: #fff;
  text-shadow: 0 0 14px rgba(192, 132, 252, 0.9);
}

.catalog-hero p {
  color: rgba(243, 232, 255, 0.78);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  margin-top: 8px;
}

.catalog-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px clamp(4px, 1.8vw, 10px) 12px;
  scrollbar-width: none;
}

.catalog-tabs::-webkit-scrollbar {
  display: none;
}

.catalog-tab {
  flex: 0 0 auto;
  border: 1px solid rgba(168, 85, 247, 0.28);
  background: rgba(8, 4, 18, 0.65);
  color: rgba(243, 232, 255, 0.72);
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}

.catalog-tab.active {
  color: #fff;
  border-color: rgba(192, 132, 252, 0.75);
  background: rgba(12, 7, 26, 0.5);
  text-shadow: var(--lux-neon-text);
  filter: var(--lux-neon-icon);
  box-shadow: var(--lux-neon-box);
}

body.theme-light .catalog-tabs {
  background: rgba(255, 247, 252, 0.54);
  border-color: rgba(177, 120, 219, 0.22);
  box-shadow: 0 14px 30px rgba(154, 79, 103, 0.12);
}

body.theme-light .catalog-tab {
  color: rgba(70, 48, 88, 0.78);
  background: rgba(255, 247, 252, 0.58);
  border-color: rgba(177, 120, 219, 0.28);
}

body.theme-light .catalog-tab.active {
  color: #8a32d4;
  background: rgba(255, 247, 252, 0.86);
  border-color: rgba(168, 85, 247, 0.52);
  text-shadow: var(--lux-neon-text);
  filter: var(--lux-neon-icon);
  box-shadow: var(--lux-neon-box);
}

.catalog-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 6px 12px;
}

.catalog-heading-row span {
  color: rgba(216, 202, 255, 0.68);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2.6vw, 16px) clamp(8px, 2.4vw, 14px);
  justify-content: center;
}

.npc-view {
  padding: 0 clamp(10px, 3vw, 18px) 88px;
}

.npc-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 6px 14px;
}

.npc-sort-btn {
  border: 1px solid rgba(168, 85, 247, 0.24);
  border-radius: 14px;
  background: rgba(14, 12, 34, 0.86);
  color: rgba(243, 232, 255, 0.82);
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
}

.npc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2.6vw, 16px) clamp(8px, 2.4vw, 14px);
  justify-content: center;
}

.npc-card {
  position: relative;
  border: 1px solid rgba(168, 85, 247, 0.45);
  border-radius: 12px;
  overflow: hidden;
  min-height: clamp(150px, 33vw, 220px);
  aspect-ratio: 0.72;
  padding: 0;
  background: rgba(12, 7, 26, 0.85);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(91, 33, 182, 0.2);
}

.npc-card.active {
  border-color: var(--accent-neon);
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.65);
}

.npc-card.ratio-square,
.catalog-card.ratio-square,
.story-card.ratio-square {
  aspect-ratio: 1 / 1;
}

.npc-card.ratio-portrait,
.catalog-card.ratio-portrait,
.story-card.ratio-portrait {
  aspect-ratio: 3 / 4;
}

.npc-card.ratio-tall,
.catalog-card.ratio-tall,
.story-card.ratio-tall {
  aspect-ratio: 9 / 16;
}

.npc-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.npc-card::after {
  content: "";
  position: absolute;
  inset: 34% 0 0;
  background: linear-gradient(180deg, rgba(8, 4, 18, 0), rgba(8, 4, 18, 0.96));
  pointer-events: none;
}

.npc-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  max-width: calc(100% - 54px);
  border-radius: 9px;
  background: rgba(34, 24, 73, 0.88);
  color: rgba(243, 232, 255, 0.86);
  padding: 5px 8px;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.npc-info {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 180, 254, 0.78);
  border-radius: 50%;
  color: rgba(243, 232, 255, 0.9);
  font-size: 13px;
  font-weight: 800;
}

.npc-card-overlay {
  position: absolute;
  left: 10px;
  right: 38px;
  bottom: 14px;
  z-index: 2;
  text-align: left;
}

.npc-card-overlay strong {
  display: block;
  color: #fff;
  font-size: 16px;
  line-height: 1.05;
  font-weight: 800;
  text-transform: uppercase;
}

.npc-card-overlay span {
  display: block;
  color: rgba(243, 232, 255, 0.72);
  font-size: 8px;
  line-height: 1.28;
  font-weight: 700;
  margin-top: 7px;
}

.npc-add {
  position: absolute;
  right: 10px;
  bottom: 12px;
  z-index: 3;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(192, 132, 252, 0.8);
  border-radius: 7px;
  color: #fff;
  background: rgba(91, 33, 182, 0.66);
  box-shadow: 0 0 14px rgba(147, 51, 234, 0.52);
  font-size: 22px;
  line-height: 1;
}

.catalog-card {
  position: relative;
  border: 1px solid rgba(168, 85, 247, 0.45);
  border-radius: 12px;
  overflow: hidden;
  min-height: clamp(150px, 33vw, 220px);
  aspect-ratio: 0.72;
  padding: 0;
  background: rgba(12, 7, 26, 0.85);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(91, 33, 182, 0.2);
}

.catalog-card.active {
  border-color: var(--accent-neon);
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.65);
}

.catalog-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.catalog-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  background: linear-gradient(180deg, rgba(8, 4, 18, 0), rgba(8, 4, 18, 0.46) 58%, rgba(8, 4, 18, 0.76));
  pointer-events: none;
}

.catalog-favorite {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 2;
  color: #fff;
  font-size: 22px;
  text-shadow: 0 0 10px rgba(8, 4, 18, 0.8);
}

/* Сердечко маленькое — невидимая зона вокруг, чтобы в него легко попасть пальцем */
.catalog-favorite::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.catalog-favorite.active {
  color: #ff7ab8;
  text-shadow: 0 0 14px rgba(255, 82, 170, 0.82);
}

.catalog-card.active .catalog-favorite:not(.active) {
  color: var(--accent-neon);
}

.favorite-character-card {
  border-color: rgba(255, 122, 184, 0.58);
}

.catalog-card-overlay {
  position: absolute;
  left: 10px;
  right: 8px;
  bottom: 10px;
  z-index: 2;
  text-align: left;
}

.catalog-card-overlay strong {
  display: block;
  color: #fff;
  font-size: 17px;
  line-height: 1.05;
  font-weight: 800;
  text-transform: uppercase;
}

.catalog-card-overlay span {
  display: block;
  color: rgba(243, 232, 255, 0.72);
  font-size: 8px;
  line-height: 1.25;
  font-weight: 800;
  text-transform: uppercase;
  margin-top: 5px;
}

.catalog-empty {
  grid-column: 1 / -1;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 18px;
  color: rgba(243, 232, 255, 0.72);
  text-align: center;
}

.catalog-loading {
  grid-column: 1 / -1;
  min-height: 190px;
  border: 1px solid rgba(244, 114, 182, 0.42);
  border-radius: var(--radius-md);
  padding: 26px 18px;
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  color: rgba(255, 237, 247, 0.92);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(244, 114, 182, 0.08));
  box-shadow: inset 0 0 24px rgba(244, 114, 182, 0.12), 0 0 24px rgba(236, 72, 153, 0.12);
}

.catalog-loader-book {
  position: relative;
  width: 58px;
  height: 46px;
  perspective: 180px;
}

.catalog-loader-book::before,
.catalog-loader-book::after,
.catalog-loader-book span {
  content: "";
  position: absolute;
  inset: 4px 7px;
  border: 1px solid rgba(255, 201, 229, 0.78);
  border-radius: 8px 3px 3px 8px;
  background: linear-gradient(135deg, rgba(255, 244, 250, 0.92), rgba(248, 187, 217, 0.66));
  box-shadow: 0 8px 18px rgba(80, 18, 58, 0.24);
  transform-origin: left center;
}

.catalog-loader-book::before {
  transform: rotateY(-26deg);
}

.catalog-loader-book::after {
  border-radius: 3px 8px 8px 3px;
  transform-origin: right center;
  transform: translateX(16px) rotateY(26deg);
}

.catalog-loader-book span {
  animation: catalog-page-turn 1.45s ease-in-out infinite;
}

.catalog-loader-book span:nth-child(2) {
  animation-delay: 0.18s;
  opacity: 0.74;
}

.catalog-loader-book span:nth-child(3) {
  animation-delay: 0.36s;
  opacity: 0.54;
}

.catalog-loader-star {
  margin-top: -6px;
  color: var(--accent-neon);
  font-size: 24px;
  text-shadow: 0 0 14px rgba(244, 114, 182, 0.9);
  animation: catalog-star-pulse 1.2s ease-in-out infinite;
}

.catalog-loading strong,
.catalog-loading small {
  display: block;
}

.catalog-loading strong {
  font-size: 16px;
  color: #fff;
}

.catalog-loading small {
  color: rgba(255, 220, 239, 0.78);
  font-size: 12px;
}

@keyframes catalog-page-turn {
  0%, 100% {
    transform: rotateY(-8deg) translateX(0);
  }
  45% {
    transform: rotateY(-68deg) translateX(4px);
  }
}

@keyframes catalog-star-pulse {
  0%, 100% {
    transform: scale(0.92) rotate(0deg);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.12) rotate(12deg);
    opacity: 1;
  }
}

.catalog-create-cta {
  width: 100%;
  margin-top: 18px;
  border: 1px solid rgba(192, 132, 252, 0.72);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(89, 24, 180, 0.86), rgba(74, 13, 116, 0.65));
  color: #fff;
  padding: 14px;
  display: grid;
  grid-template-columns: 48px 1fr 18px;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(147, 51, 234, 0.52);
}

.catalog-create-icon {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(192, 132, 252, 0.55);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--accent-neon);
  font-size: 22px;
  box-shadow: inset 0 0 16px rgba(147, 51, 234, 0.35);
}

.catalog-create-cta b,
.catalog-create-cta small {
  display: block;
}

.catalog-create-cta b {
  font-size: 13px;
  letter-spacing: 0.2px;
}

.catalog-create-cta small {
  color: rgba(216, 202, 255, 0.7);
  font-size: 10px;
  margin-top: 3px;
}

.catalog-create-arrow {
  color: var(--accent-neon);
  font-size: 30px;
  line-height: 1;
}

.story-view {
  padding: 0 clamp(10px, 3vw, 18px) 88px;
}

.story-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.story-filter-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(168, 85, 247, 0.24);
  border-radius: 50%;
  background: rgba(14, 12, 34, 0.86);
  color: var(--accent-neon);
  font-size: 20px;
  cursor: pointer;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2.6vw, 16px) clamp(8px, 2.4vw, 14px);
  justify-content: center;
}

.story-card {
  position: relative;
  min-height: clamp(152px, 34vw, 224px);
  aspect-ratio: 0.72;
  border: 1px solid rgba(168, 85, 247, 0.45);
  border-radius: 12px;
  overflow: hidden;
  padding: 0;
  background: rgba(12, 7, 26, 0.85);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(91, 33, 182, 0.2);
}

.story-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-card::after {
  content: "";
  position: absolute;
  inset: 32% 0 0;
  background: linear-gradient(180deg, rgba(8, 4, 18, 0), rgba(8, 4, 18, 0.95));
}

.story-badge,
.story-crown,
.story-unique,
.story-info,
.story-card-action,
.story-card-overlay {
  position: absolute;
  z-index: 2;
}

.story-badge {
  top: 10px;
  left: 10px;
  border-radius: 8px;
  padding: 5px 8px;
  color: #fff;
  background: rgba(22, 101, 52, 0.78);
  font-size: 8px;
  font-weight: 800;
}

.story-card.medium .story-badge {
  background: rgba(146, 64, 14, 0.82);
}

.story-card.full .story-badge {
  background: rgba(159, 18, 57, 0.82);
}

.story-crown,
.story-unique {
  top: 12px;
  right: 14px;
  color: #facc15;
  font-size: 20px;
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.75);
}

.story-unique {
  color: #f0abfc;
}

.story-info {
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 180, 254, 0.76);
  border-radius: 50%;
  color: rgba(243, 232, 255, 0.9);
  font-size: 13px;
  font-weight: 800;
}

.story-crown + .story-info,
.story-unique + .story-info {
  display: none;
}

.story-card-overlay {
  left: 12px;
  right: 40px;
  bottom: 18px;
  text-align: left;
}

.story-card-overlay strong {
  display: block;
  color: #fff;
  font-size: 15px;
  line-height: 1.15;
  font-weight: 800;
  text-transform: uppercase;
}

.story-card-overlay small {
  display: block;
  color: rgba(243, 232, 255, 0.72);
  font-size: 9px;
  line-height: 1.3;
  margin-top: 10px;
}

.story-card-action {
  right: 10px;
  bottom: 14px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(192, 132, 252, 0.8);
  border-radius: 7px;
  color: #fff;
  background: rgba(91, 33, 182, 0.66);
  box-shadow: 0 0 14px rgba(147, 51, 234, 0.52);
  font-size: 17px;
}

.story-card.locked img {
  filter: brightness(0.68) saturate(0.86);
}

.story-detail {
  border: 1px solid rgba(168, 85, 247, 0.28);
  border-radius: 18px;
  background: rgba(7, 14, 31, 0.62);
  overflow: hidden;
}

.story-back-link {
  margin: 20px 18px 10px;
  border: 0;
  background: transparent;
  color: #f0abfc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  cursor: pointer;
}

.story-detail-hero {
  position: relative;
  min-height: 420px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  align-items: center;
  gap: 12px;
}

.story-detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(3, 7, 18, 0.98) 0%, rgba(3, 7, 18, 0.74) 42%, rgba(3, 7, 18, 0.08) 100%);
  pointer-events: none;
}

.story-detail-copy,
.story-detail-hero img {
  position: relative;
  z-index: 1;
}

.story-detail-copy h1 {
  color: #fff;
  font-size: 40px;
  line-height: 1.08;
  font-weight: 500;
  letter-spacing: 1px;
  margin: 28px 0 16px;
  text-shadow: 0 0 16px rgba(192, 132, 252, 0.5);
}

.story-detail-copy p,
.story-info-block p,
.story-tip p,
.story-feature-grid p {
  color: rgba(243, 232, 255, 0.75);
  line-height: 1.55;
}

.story-detail-hero img {
  width: 100%;
  height: 390px;
  object-fit: cover;
  border-radius: 12px;
}

.story-level-pill {
  display: inline-block;
  border-radius: 12px;
  padding: 8px 13px;
  background: rgba(22, 101, 52, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.story-level-pill.medium {
  background: rgba(146, 64, 14, 0.85);
}

.story-level-pill.full {
  background: rgba(159, 18, 57, 0.85);
}

.story-separator {
  width: 80%;
  height: 1px;
  margin: 26px 0;
  background: linear-gradient(90deg, var(--accent-neon), transparent);
}

.story-meta-list {
  display: grid;
  gap: 16px;
}

.story-meta-list div {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 4px 12px;
  align-items: center;
}

.story-meta-list span {
  grid-row: span 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent-neon);
  background: rgba(30, 41, 59, 0.55);
}

.story-meta-list b {
  color: #fff;
  font-size: 11px;
}

.story-meta-list small {
  color: rgba(216, 202, 255, 0.82);
}

.story-info-block {
  border-top: 1px solid rgba(168, 85, 247, 0.16);
  padding: 22px 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: center;
}

.story-info-block img {
  display: none;
}

.story-expects {
  border-top: 1px solid rgba(168, 85, 247, 0.16);
  padding: 22px 18px;
}

.story-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.story-feature-grid article {
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 12px;
  min-height: 138px;
  padding: 16px 12px;
  background: rgba(7, 14, 31, 0.7);
}

.story-feature-grid span {
  color: var(--accent-neon);
  font-size: 26px;
}

.story-feature-grid b {
  display: block;
  color: #fff;
  font-size: 12px;
  margin: 12px 0 8px;
  text-transform: uppercase;
}

.story-feature-grid p,
.story-tip p {
  font-size: 12px;
}

.story-tip {
  margin: 0 18px 18px;
  border: 1px solid rgba(192, 132, 252, 0.55);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  background: rgba(76, 29, 149, 0.12);
}

.story-tip span {
  color: var(--accent-neon);
  font-size: 34px;
}

.story-tip b {
  color: #f4d9ff;
  font-size: 13px;
  letter-spacing: 2px;
}

.story-actions {
  padding: 0 18px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.story-actions button {
  min-height: 54px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.7px;
  cursor: pointer;
}

.primary-action {
  border: 1px solid rgba(192, 132, 252, 0.74);
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.9), rgba(88, 28, 135, 0.75));
  text-shadow: var(--lux-neon-text);
  box-shadow: var(--lux-neon-box);
}

.primary-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary-action {
  border: 1px solid rgba(168, 85, 247, 0.42);
  color: #f0abfc;
  background: rgba(8, 4, 18, 0.45);
}

.premium-view {
  padding: 16px;
}

.premium-panel {
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 18px;
  background: rgba(8, 13, 30, 0.72);
  padding: 16px;
  box-shadow: 0 0 28px rgba(147, 51, 234, 0.18);
}

.premium-title-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-bottom: 20px;
}

.premium-title-row h2 {
  color: #f4d9ff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1.5px;
}

.premium-title-row p {
  color: rgba(216, 202, 255, 0.86);
  font-size: 13px;
  margin-top: 8px;
}

.premium-back {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(168, 85, 247, 0.42);
  border-radius: 50%;
  color: var(--accent-neon);
  background: rgba(76, 29, 149, 0.36);
  font-size: 38px;
  line-height: 0.75;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(147, 51, 234, 0.25);
}

.premium-hero {
  position: relative;
  min-height: 220px;
  border: 1px solid rgba(168, 85, 247, 0.42);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(12, 7, 26, 0.85);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.premium-hero img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
  display: block;
}

.premium-hero::after {
  content: "";
  position: absolute;
  inset: 35% 0 0;
  background: linear-gradient(180deg, transparent, rgba(3, 2, 12, 0.95));
}

.premium-hero-content {
  position: absolute;
  z-index: 1;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
}

.premium-hero-content strong,
.premium-hero-content span {
  display: block;
}

.premium-hero-content strong {
  color: #fff;
  font-size: 22px;
  margin-bottom: 10px;
}

.premium-hero-content span {
  color: rgba(243, 232, 255, 0.8);
  font-size: 14px;
  line-height: 1.45;
}

.premium-activate,
.premium-select-plan {
  border: 1px solid rgba(192, 132, 252, 0.74);
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.9), rgba(88, 28, 135, 0.75));
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.4px;
  box-shadow: 0 0 18px rgba(147, 51, 234, 0.35);
}

.premium-activate {
  min-width: 150px;
  padding: 14px 18px;
  font-size: 12px;
}

.premium-section-title {
  color: #e9b8ff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1.3px;
  margin: 28px 2px 16px;
}

.premium-benefits {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.premium-benefits article,
.premium-plan-card {
  border: 1px solid rgba(168, 85, 247, 0.24);
  border-radius: 12px;
  background: rgba(7, 14, 31, 0.74);
  box-shadow: inset 0 0 30px rgba(15, 23, 42, 0.42);
}

.premium-benefits article {
  min-height: 134px;
  padding: 16px 10px;
  text-align: center;
  display: grid;
  align-content: start;
  gap: 10px;
}

.premium-benefits span {
  color: var(--accent-neon);
  font-size: 30px;
  line-height: 1;
}

.premium-benefits b {
  color: #fff;
  font-size: 13px;
  line-height: 1.25;
}

.premium-benefits small {
  color: rgba(216, 202, 255, 0.78);
  font-size: 10px;
  line-height: 1.45;
}

.premium-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.premium-plan-card {
  position: relative;
  padding: 34px 12px 12px;
}

.premium-plan-card.featured {
  border-color: rgba(192, 132, 252, 0.9);
  box-shadow: 0 0 24px rgba(147, 51, 234, 0.28);
}

.premium-plan-badge {
  position: absolute;
  top: -1px;
  right: 10px;
  border-radius: 0 0 8px 8px;
  background: rgba(147, 51, 234, 0.9);
  color: #fff;
  padding: 5px 9px;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.premium-plan-card:nth-child(2) .premium-plan-badge {
  background: rgba(16, 185, 129, 0.35);
}

.premium-plan-card:nth-child(3) .premium-plan-badge {
  background: rgba(234, 179, 8, 0.24);
}

.premium-plan-card:nth-child(4) .premium-plan-badge {
  background: rgba(14, 165, 233, 0.28);
}

.premium-plan-card h4 {
  color: #e9b8ff;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 14px;
}

.premium-plan-note {
  max-width: calc(100% - 92px);
  margin: -22px 0 12px;
  color: rgba(243, 232, 255, 0.58);
  font-size: 9px;
  font-weight: 500;
  line-height: 1.35;
}

.premium-price-row {
  min-height: 46px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 16px;
}

.premium-price-row strong {
  color: #bd21ff;
  font-size: 23px;
  font-weight: 500;
}

.premium-price-row small,
.premium-price-row del {
  color: rgba(243, 232, 255, 0.62);
  font-size: 11px;
}

.premium-price-row em {
  background: var(--accent-purple);
  color: #fff;
  border-radius: 6px;
  padding: 3px 5px;
  font-size: 10px;
  font-style: normal;
}

.premium-plan-card ul {
  list-style: none;
  color: rgba(243, 232, 255, 0.78);
  font-size: 11px;
  line-height: 1.6;
  min-height: 100px;
}

.premium-select-plan {
  width: 100%;
  padding: 12px;
  margin-top: 14px;
  background: rgba(56, 14, 94, 0.62);
  font-size: 11px;
}

.premium-select-plan:disabled,
.premium-plan-card.is-unavailable .premium-select-plan {
  cursor: default;
  opacity: 0.65;
  filter: grayscale(0.2);
}

.premium-plan-card.is-unavailable {
  opacity: 0.86;
}

.premium-footer-links {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  margin-top: 18px;
}

.premium-footer-links p {
  color: rgba(216, 202, 255, 0.62);
  font-size: 11px;
  line-height: 1.45;
}

.premium-footer-links div {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.premium-footer-links button {
  border: none;
  background: transparent;
  color: rgba(216, 202, 255, 0.88);
  text-decoration: underline;
  font-size: 11px;
  cursor: pointer;
}

.subscription-view {
  padding: 16px 14px 120px;
}

.roleplay-mode-list {
  display: grid;
  gap: 10px;
}

.roleplay-mode-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(181, 93, 255, 0.26);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  color: #f4f0fb;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.roleplay-mode-card span {
  display: grid;
  gap: 4px;
}

.roleplay-mode-card strong {
  font-size: 15px;
}

.roleplay-mode-card small {
  color: rgba(244, 240, 251, 0.66);
  font-size: 13px;
  line-height: 1.35;
}

.roleplay-mode-card > i {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(181, 93, 255, 0.55);
  border-radius: 50%;
}

.roleplay-mode-card.active {
  border-color: rgba(214, 120, 255, 0.85);
  background: linear-gradient(135deg, rgba(139, 61, 255, 0.22), rgba(255, 79, 163, 0.12));
}

.roleplay-mode-card.active > i {
  border-color: #ff6fb5;
  background: radial-gradient(circle, #ff6fb5 0 4px, transparent 5px);
}

.roleplay-mode-card.is-locked {
  opacity: 0.62;
}

.roleplay-mode-lock {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 204, 102, 0.14);
  color: #ffd27a;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

/* The fourth card starts the modes of every plan. */
.roleplay-mode-card[data-roleplay-mode="story"] {
  margin-top: 8px;
}

body.theme-light .roleplay-mode-card {
  background: rgba(255, 255, 255, 0.72);
  color: #392244;
}

body.theme-light .roleplay-mode-card small {
  color: rgba(68, 42, 77, 0.72);
}

.subscription-panel {
  border: 1px solid rgba(181, 93, 255, 0.42);
  background: linear-gradient(180deg, rgba(24, 13, 45, 0.94), rgba(9, 4, 20, 0.94));
  border-radius: 28px;
  padding: 22px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.terms-view {
  padding: 16px 14px 120px;
}

.terms-panel {
  border: 1px solid rgba(181, 93, 255, 0.42);
  background: linear-gradient(180deg, rgba(24, 13, 45, 0.94), rgba(9, 4, 20, 0.94));
  border-radius: 28px;
  padding: 22px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.terms-content {
  margin-top: 18px;
  color: rgba(243, 232, 255, 0.76);
  font-size: 12px;
  line-height: 1.58;
}

.terms-content h3,
.terms-content h4 {
  color: #e9b8ff;
  font-weight: 700;
}

.terms-content h3 {
  margin-bottom: 12px;
  font-size: 17px;
}

.terms-content h4 {
  margin: 20px 0 8px;
  font-size: 13px;
}

.terms-content p {
  margin: 0 0 10px;
}

/* «Пользовательское соглашение» is a long title: keep it inside a phone screen. */
.terms-panel .settings-history-head h2 {
  font-size: clamp(22px, 6.4vw, 30px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.terms-content ul {
  margin: 0 0 10px;
  padding-left: 18px;
}

.terms-content li {
  margin-bottom: 6px;
}

.terms-content .terms-meta {
  margin-top: -6px;
  color: rgba(243, 232, 255, 0.5);
  font-size: 11px;
}

.subscription-status-card {
  margin-top: 24px;
  border: 1px solid rgba(181, 93, 255, 0.34);
  border-radius: 18px;
  background: rgba(16, 8, 34, 0.88);
  padding: 20px;
}

.subscription-vision-card {
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 80, 182, 0.16), transparent 36%),
    rgba(16, 8, 34, 0.88);
}

.subscription-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #8b35ee, #f450b6);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.subscription-status-badge.cancelled {
  background: rgba(255, 93, 151, 0.18);
  border: 1px solid rgba(255, 93, 151, 0.55);
  color: #ff8dbc;
}

.subscription-status-card h3 {
  margin: 16px 0 8px;
  color: #fff;
  font-size: 30px;
  line-height: 1;
}

.subscription-status-card p {
  margin: 0;
  color: rgba(223, 190, 255, 0.82);
  font-size: 15px;
  line-height: 1.45;
}

.subscription-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.subscription-meta-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.subscription-meta div {
  border: 1px solid rgba(181, 93, 255, 0.25);
  border-radius: 14px;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.035);
}

.subscription-meta span,
.subscription-note {
  color: rgba(223, 190, 255, 0.7);
  font-size: 12px;
}

.subscription-meta b {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: 14px;
}

.subscription-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 18px;
}

.subscription-actions button {
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid rgba(181, 93, 255, 0.5);
  background: linear-gradient(135deg, #8b35ee, #f450b6);
  color: #fff;
  font-weight: 800;
}

.subscription-actions .subscription-cancel-btn {
  background: rgba(255, 93, 151, 0.1);
  color: #ff8dbc;
  border-color: rgba(255, 93, 151, 0.5);
}

.subscription-actions button:disabled {
  opacity: 0.55;
}

.subscription-note {
  margin: 14px 2px 0;
  line-height: 1.45;
}

.subscription-tribute-warning {
  margin-top: 16px;
  border: 1px solid rgba(255, 93, 151, 0.42);
  border-radius: 16px;
  background: rgba(255, 93, 151, 0.1);
  padding: 16px;
}

.subscription-tribute-warning[hidden] {
  display: none;
}

.subscription-tribute-warning b {
  display: block;
  color: #ff8dbc;
  font-size: 15px;
  margin-bottom: 8px;
}

.subscription-tribute-warning p {
  margin: 0;
  color: rgba(255, 225, 239, 0.86);
  font-size: 13px;
  line-height: 1.45;
}

.subscription-tribute-warning button {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 93, 151, 0.55);
  background: rgba(255, 93, 151, 0.14);
  color: #fff;
  font-weight: 800;
}

.settings-view {
  padding: 16px;
}

.settings-profile-panel,
.settings-list {
  border: 1px solid var(--card-border);
  border-radius: 18px;
  background: var(--card-bg);
  box-shadow: 0 0 28px rgba(147, 51, 234, 0.16);
  overflow: hidden;
}

.settings-profile-panel {
  padding: 18px;
}

.settings-profile-top {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  align-items: center;
}

.settings-avatar-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  min-width: 140px;
  overflow: visible;
}

.settings-avatar-wrap img {
  display: block;
  width: 140px;
  height: 140px;
  max-width: 140px;
  min-width: 140px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  border: 2px solid var(--accent-neon);
  box-shadow: 0 0 24px rgba(192, 132, 252, 0.5);
  overflow: hidden;
  text-indent: 150%;
  white-space: nowrap;
}

.settings-avatar-edit {
  position: absolute;
  right: 0;
  bottom: 6px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--accent-neon);
  background: var(--card-bg);
  color: var(--accent-neon);
  font-size: 18px;
  cursor: pointer;
}

.settings-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(100%, 340px);
}

.settings-name-input {
  width: 100%;
  min-width: 0;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: var(--text-main);
  font-size: 30px;
  font-weight: 700;
  outline: none;
  box-shadow: none !important;
}

.settings-profile-save-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(192, 132, 252, 0.58);
  border-radius: 50%;
  background: rgba(80, 34, 138, 0.45);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.2);
}

.settings-profile-save-btn:hover {
  border-color: var(--accent-neon);
  background: rgba(124, 58, 237, 0.62);
}

.settings-username-row {
  display: flex;
  align-items: center;
  max-width: min(100%, 340px);
}

.settings-username-field {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid rgba(192, 132, 252, 0.34);
  border-radius: 999px;
  background: rgba(8, 4, 18, 0.36);
  color: var(--text-muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.settings-username-field span {
  flex: 0 0 auto;
  color: var(--accent-neon);
  font-weight: 800;
  line-height: 1;
}

.settings-username-field input {
  width: min(220px, 48vw);
  min-width: 0;
  border: 0;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  caret-color: var(--accent-neon);
  box-shadow: none !important;
}

.settings-username-field input:-webkit-autofill,
.settings-username-field input:-webkit-autofill:hover,
.settings-username-field input:-webkit-autofill:focus,
.home-author-search input:-webkit-autofill,
.home-author-search input:-webkit-autofill:hover,
.home-author-search input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-main);
  caret-color: var(--accent-neon);
  -webkit-box-shadow: 0 0 0 1000px #130a25 inset !important;
  box-shadow: 0 0 0 1000px #130a25 inset !important;
  transition: background-color 9999s ease-in-out 0s;
}

.settings-username-field input::placeholder {
  color: color-mix(in srgb, var(--text-muted) 72%, transparent);
}

body.theme-light .settings-username-field {
  background: rgba(255, 247, 252, 0.34);
  border-color: rgba(255, 79, 163, 0.28);
}

body.theme-light .settings-profile-save-btn {
  background: rgba(255, 247, 252, 0.48);
  border-color: rgba(255, 63, 154, 0.28);
  color: #7a2350;
  box-shadow: 0 0 14px rgba(255, 63, 154, 0.16);
}

body.theme-light .settings-username-field input {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: #251334;
  color-scheme: light;
}

body.theme-light .settings-username-field input:-webkit-autofill,
body.theme-light .settings-username-field input:-webkit-autofill:hover,
body.theme-light .settings-username-field input:-webkit-autofill:focus,
body.theme-light .home-author-search input:-webkit-autofill,
body.theme-light .home-author-search input:-webkit-autofill:hover,
body.theme-light .home-author-search input:-webkit-autofill:focus {
  -webkit-text-fill-color: #251334;
  -webkit-box-shadow: 0 0 0 1000px #fdf3fb inset !important;
  box-shadow: 0 0 0 1000px #fdf3fb inset !important;
}

.settings-subscription-line {
  margin-top: 12px;
  color: var(--accent-neon);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.settings-online-dot {
  display: inline-block;
  margin-top: 12px;
  padding: 7px 12px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.settings-online-dot::first-letter {
  color: #34d399;
}

.settings-motto {
  margin-top: 16px;
  max-width: 360px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.035);
}

.settings-motto span,
.settings-motto button {
  color: var(--accent-neon);
}

.settings-motto span {
  align-self: start;
  font-size: 22px;
  line-height: 1;
}

.settings-motto textarea {
  width: 100%;
  min-height: 24px;
  max-height: 54px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.35;
}

.settings-motto button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}

.settings-counters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 22px -18px 18px;
  padding: 20px 18px;
  border-top: 1px solid var(--card-border);
  border-bottom: 1px solid var(--card-border);
}

.settings-counters div {
  text-align: center;
}

.settings-counters strong,
.settings-counters span {
  display: block;
}

.settings-counters strong {
  color: var(--accent-neon);
  font-size: 30px;
  font-weight: 600;
}

.settings-counters span {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 5px;
}

.settings-achievements h3,
.settings-main-title {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

/* Hidden achievements: the block shows only once one is earned. */
.settings-achievements:not(.has-achievements) {
  display: none !important;
}

.settings-achievements.has-achievements {
  margin-top: 18px;
}

.settings-history-view {
  padding: 10px clamp(12px, 3vw, 20px) 96px;
}

.settings-history-panel {
  border: 1px solid rgba(176, 104, 255, 0.28);
  border-radius: 24px;
  padding: clamp(18px, 4vw, 28px);
  background: rgba(7, 10, 24, 0.72);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.settings-history-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.settings-history-head span {
  display: block;
  color: var(--accent-neon);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.settings-history-head h2 {
  margin: 4px 0;
  color: var(--text-main);
  font-size: clamp(28px, 6vw, 38px);
}

.settings-history-head p {
  margin: 0;
  color: var(--text-muted);
}

.settings-history-head b {
  color: var(--accent-neon);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 8px 12px;
}

.settings-history-back {
  width: 42px;
  height: 42px;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  background: rgba(123, 31, 255, 0.18);
  color: var(--accent-neon);
  font-size: 34px;
  line-height: 1;
}

.settings-history-grid {
  margin-top: 18px;
}

.story-history-card {
  min-height: 240px;
}

.history-character-card {
  cursor: pointer;
}

body.theme-light .settings-history-panel {
  background: rgba(255, 244, 236, 0.82);
  border-color: rgba(255, 74, 155, 0.28);
  box-shadow: 0 18px 50px rgba(126, 74, 54, 0.16);
}

body.theme-light .settings-history-head h2,
body.theme-light .settings-history-head p,
body.theme-light .settings-history-head b,
body.theme-light .settings-history-head span {
  color: #7c3e3a;
  text-shadow: 0 0 14px rgba(255, 80, 166, 0.28);
}

body.theme-light .settings-history-back {
  background: rgba(255, 231, 221, 0.88);
  border-color: rgba(255, 74, 155, 0.35);
  color: #ff4aa0;
  box-shadow: 0 0 18px rgba(255, 80, 166, 0.24);
}

body.theme-light .subscription-panel {
  background:
    radial-gradient(circle at 82% 0%, rgba(255, 79, 163, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(255, 246, 239, 0.96), rgba(244, 221, 211, 0.9));
  border-color: rgba(255, 92, 166, 0.3);
  box-shadow:
    0 16px 34px rgba(154, 79, 103, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

body.theme-light .terms-panel {
  background:
    radial-gradient(circle at 82% 0%, rgba(255, 79, 163, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(255, 246, 239, 0.96), rgba(244, 221, 211, 0.9));
  border-color: rgba(255, 92, 166, 0.3);
  box-shadow:
    0 16px 34px rgba(154, 79, 103, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

body.theme-light .terms-content {
  color: #7c3e3a;
}

body.theme-light .terms-content h3,
body.theme-light .terms-content h4 {
  color: #8a3156;
  text-shadow: 0 0 9px rgba(255, 79, 163, 0.18);
}

body.theme-light .subscription-status-card,
body.theme-light .subscription-meta div {
  background: rgba(255, 252, 247, 0.72);
  border-color: rgba(255, 92, 166, 0.26);
  box-shadow: 0 10px 24px rgba(154, 79, 103, 0.08);
}

body.theme-light .subscription-vision-card {
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 79, 163, 0.15), transparent 36%),
    rgba(255, 252, 247, 0.72);
}

body.theme-light .subscription-status-card h3,
body.theme-light .subscription-meta b {
  color: #8a3156;
  text-shadow: 0 0 9px rgba(255, 79, 163, 0.18);
}

body.theme-light .subscription-status-card p,
body.theme-light .subscription-meta span,
body.theme-light .subscription-note {
  color: #9e4967;
}

body.theme-light .subscription-status-badge {
  background: linear-gradient(135deg, #ff7fbd, #b74577);
  color: #fff8fb;
  box-shadow: 0 0 18px rgba(255, 63, 154, 0.28);
}

body.theme-light .subscription-status-badge.cancelled {
  background: rgba(255, 97, 147, 0.16);
  border-color: rgba(197, 55, 107, 0.36);
  color: #b43367;
  box-shadow: none;
}

body.theme-light .subscription-actions button {
  background: linear-gradient(135deg, #ff7fbd, #b74577);
  border-color: rgba(255, 159, 208, 0.72);
  color: #fff8fb;
  box-shadow: 0 0 20px rgba(255, 63, 154, 0.26);
}

body.theme-light .subscription-actions .subscription-cancel-btn {
  background: rgba(255, 97, 147, 0.12);
  border-color: rgba(197, 55, 107, 0.34);
  color: #b43367;
  box-shadow: none;
}

body.theme-light .subscription-tribute-warning {
  background: rgba(255, 97, 147, 0.12);
  border-color: rgba(197, 55, 107, 0.34);
}

body.theme-light .subscription-tribute-warning b {
  color: #b43367;
}

body.theme-light .subscription-tribute-warning p {
  color: #8a3156;
}

body.theme-light .subscription-tribute-warning button {
  background: rgba(255, 97, 147, 0.14);
  border-color: rgba(197, 55, 107, 0.38);
  color: #8a3156;
}

.achievement-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

.achievement-badge {
  --badge-color: #9333ea;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 12px 8px;
  border: 1px solid color-mix(in srgb, var(--badge-color) 40%, transparent);
  border-radius: 16px;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--badge-color) 18%, transparent), transparent 70%);
  text-align: center;
}

.achievement-badge.is-author {
  --badge-color: #db2777;
}

.achievement-badge.is-halloween {
  --badge-color: #ea580c;
}

.achievement-badge i {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--badge-color);
  box-shadow: 0 0 14px color-mix(in srgb, var(--badge-color) 55%, transparent), inset 0 0 10px color-mix(in srgb, var(--badge-color) 30%, transparent);
}

.achievement-badge svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--badge-color);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.achievement-badge strong {
  font-size: 12px;
  line-height: 1.2;
}

.achievement-badge small {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.3;
}

/* Achievement decorations (achievements.py rewards): neon line frames and glows around the
   picture in deep saturated colours, never mixed with white; a glowing nickname; small badges. */
[data-frame],
[data-glow] {
  border-radius: 50%;
}

[data-frame="moon"] {
  box-shadow: 0 0 0 2px #3b2fd9, 0 0 0 4px rgba(10, 6, 40, 0.9), 0 0 0 5px #6d28d9, 0 0 16px 3px rgba(67, 56, 202, 0.75);
}

[data-frame="web"] {
  outline: 2px dashed #7e22ce;
  outline-offset: 3px;
  box-shadow: 0 0 0 2px #4c1d95, 0 0 14px 3px rgba(126, 34, 206, 0.7);
}

[data-frame="blood"] {
  box-shadow: 0 0 0 2px #b0001e, 0 0 0 4px #12000a, 0 0 0 5px #7f0019, 0 0 18px 4px rgba(176, 0, 30, 0.75);
}

[data-frame="ghost"] {
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.85), 0 0 0 5px rgba(15, 118, 110, 0.35), 0 0 20px 5px rgba(13, 148, 136, 0.5);
  animation: cosmetic-ghost 4s ease-in-out infinite;
}

[data-glow="creator"]:not([data-frame]) {
  box-shadow: 0 0 0 2px #db2777, 0 0 12px 2px rgba(219, 39, 119, 0.8), 0 0 26px 6px rgba(126, 34, 206, 0.55);
  animation: cosmetic-creator 2.6s ease-in-out infinite;
}

[data-glow="pumpkin"]:not([data-frame]) {
  box-shadow: 0 0 0 2px #ea580c, 0 0 14px 3px rgba(234, 88, 12, 0.8), 0 0 28px 6px rgba(194, 65, 12, 0.5);
}

/* A frame and a glow together: the frame is the line, the glow shines around it. */
[data-frame][data-glow="creator"] { filter: drop-shadow(0 0 10px rgba(219, 39, 119, 0.65)); }
[data-frame][data-glow="pumpkin"] { filter: drop-shadow(0 0 10px rgba(234, 88, 12, 0.7)); }

[data-nick="violet"] {
  color: #a855f7 !important;
  text-shadow: 0 0 8px rgba(126, 34, 206, 0.9), 0 0 18px rgba(109, 40, 217, 0.6);
}

@keyframes cosmetic-creator {
  50% { box-shadow: 0 0 0 2px #7e22ce, 0 0 16px 3px rgba(126, 34, 206, 0.85), 0 0 32px 8px rgba(219, 39, 119, 0.5); }
}

@keyframes cosmetic-ghost {
  50% { opacity: 0.82; }
}

.cosmetic-badges {
  display: inline-flex;
  gap: 3px;
  margin-left: 5px;
  vertical-align: middle;
}

.cosmetic-badge {
  --badge-color: #a855f7;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
}

.cosmetic-badge svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--badge-color);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px var(--badge-color));
}

.cosmetic-badge[data-badge="red_flag"], .cosmetic-badge[data-badge="broken_heart"] { --badge-color: #dc2626; }
.cosmetic-badge[data-badge="flame"], .cosmetic-badge[data-badge="pumpkin"] { --badge-color: #ea580c; }
.cosmetic-badge[data-badge="portal"], .cosmetic-badge[data-badge="eye"] { --badge-color: #0891b2; }
.cosmetic-badge[data-badge="old_key"], .cosmetic-badge[data-badge="film"] { --badge-color: #d97706; }
.cosmetic-badge[data-badge="mask"], .cosmetic-badge[data-badge="quill"], .cosmetic-badge[data-badge="pen"] { --badge-color: #9333ea; }

.cosmetic-badge[data-badge="eye"] svg {
  animation: cosmetic-blink 5s ease-in-out infinite;
}

@keyframes cosmetic-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.15); }
}

/* The Halloween pumpkin: it peeks out for a few seconds; a click with the server's ticket counts. */
/* Jack's pumpkin rolls along from the left edge (app.js moves and turns it). */
.achievement-egg {
  position: fixed;
  left: 0;
  z-index: 70;
  width: 76px;
  height: 76px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 0 12px rgba(234, 88, 12, 0.8));
  will-change: transform;
}

.achievement-egg img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.achievement-egg.is-caught {
  animation: egg-caught 0.5s ease-in forwards;
}

@keyframes egg-caught {
  to { opacity: 0; scale: 1.8; rotate: 20deg; }
}

@media (prefers-reduced-motion: reduce) {
  [data-glow="creator"], [data-frame="ghost"], .cosmetic-badge svg { animation: none; }
}

/* A world opened by an achievement prize. */
.world-pass-badge {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.9), rgba(236, 72, 153, 0.9)) !important;
  color: #fff !important;
}

.world-pass-note {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.18), rgba(236, 72, 153, 0.14));
  font-size: 14px;
}

.settings-main-title {
  margin: 28px 0 14px;
}

.settings-list {
  display: grid;
  gap: 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.settings-row {
  min-height: 74px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card-bg);
  color: var(--text-main);
  padding: 0 18px;
  display: grid;
  grid-template-columns: 38px 1fr auto auto;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}

.settings-row-icon,
.settings-row i {
  color: var(--accent-neon);
  font-style: normal;
  font-size: 26px;
}

.settings-row b {
  color: var(--accent-neon);
  font-size: 15px;
  font-weight: 500;
}

.settings-row-exit,
.settings-row-exit .settings-row-icon,
.settings-row-exit i {
  color: #fb3f78;
}

.theme-switcher {
  display: flex;
  gap: 6px;
  justify-self: end;
}

.theme-switcher button {
  width: 52px;
  height: 42px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.theme-switcher button.active {
  color: var(--accent-neon);
  border-color: var(--accent-neon);
  box-shadow: 0 0 18px rgba(236, 72, 153, 0.35);
}

/* Settings tabs (Оформление, Приложение, Пригласить друзей): their own page instead of rows in the list. */
.settings-tab-list {
  margin-top: 20px;
}

.settings-tab-note {
  margin: 16px 2px 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.referral-card {
  margin-top: 20px;
  padding: 18px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  background: var(--card-bg);
}

.referral-card > span {
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.referral-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.referral-link-row input {
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font: inherit;
  font-size: 15px;
}

.referral-link-row button,
.referral-share {
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--accent-neon);
  border-radius: 12px;
  background: rgba(168, 85, 247, 0.16);
  color: var(--text-main);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.referral-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.referral-stats div {
  padding: 14px 10px;
  display: grid;
  gap: 4px;
  text-align: center;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card-bg);
}

.referral-stats strong {
  color: var(--accent-neon);
  font-size: 24px;
}

.referral-stats span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.3;
}

@media (max-width: 420px) {
  .referral-link-row {
    grid-template-columns: 1fr;
  }
}

.settings-version {
  text-align: center;
  color: var(--text-muted);
  opacity: 0.75;
  padding: 18px 0 4px;
  font-size: 12px;
}

body.theme-light .settings-profile-panel,
body.theme-light .settings-row,
body.theme-light .premium-panel,
body.theme-light .subscription-panel,
body.theme-light .premium-benefits article,
body.theme-light .premium-plan-card {
  box-shadow: 0 12px 28px rgba(236, 72, 153, 0.13);
}

body.theme-light .premium-hero::after {
  background: linear-gradient(180deg, transparent, rgba(255, 248, 238, 0.72));
}

body.theme-light .catalog-card,
body.theme-light .npc-card,
body.theme-light .story-card,
body.theme-light .story-detail,
body.theme-light .story-feature-grid article,
body.theme-light .story-tip,
body.theme-light .character-sheet-panel,
body.theme-light .section-container,
body.theme-light .gameplay-section,
body.theme-light .form-group,
body.theme-light .slider-group,
body.theme-light .segmented-group,
body.theme-light .storage-panel,
body.theme-light .slot-detail-back,
body.theme-light .slot-detail-block,
body.theme-light .saved-character-card {
  background-color: rgba(255, 252, 247, 0.82);
  color: var(--text-main);
}

body.theme-light .catalog-card-overlay,
body.theme-light .npc-card-overlay,
body.theme-light .story-card-overlay,
body.theme-light .saved-character-card::after {
  background: linear-gradient(180deg, transparent, rgba(255, 248, 238, 0.92));
}

body.theme-light .catalog-card-overlay strong,
body.theme-light .npc-card-overlay strong,
body.theme-light .story-card-overlay strong,
body.theme-light .story-detail-copy h1,
body.theme-light .story-meta-list b,
body.theme-light .story-feature-grid b,
body.theme-light .saved-character-body strong,
body.theme-light .premium-benefits b,
body.theme-light .premium-hero-content strong {
  color: var(--text-main);
}

body.theme-light .slot-detail-avatar {
  background: rgba(255, 248, 238, 0.82);
}

body.theme-light .slot-detail-avatar b {
  color: var(--text-main);
}

body.theme-light .slot-detail-block textarea {
  background: rgba(255, 252, 247, 0.72);
  color: var(--text-main);
}

body.theme-light .slot-detail-clear {
  color: #8e315a;
}

body.theme-light .catalog-card-overlay span,
body.theme-light .npc-card-overlay span,
body.theme-light .story-card-overlay small,
body.theme-light .story-detail-copy p,
body.theme-light .story-info-block p,
body.theme-light .story-tip p,
body.theme-light .story-feature-grid p,
body.theme-light .saved-character-body span,
body.theme-light .premium-benefits small,
body.theme-light .premium-hero-content span {
  color: var(--text-muted);
}

body.theme-light .avatar-meaning-note {
  border-left-color: rgba(255, 63, 154, 0.58);
  color: #9b4667;
  text-shadow: 0 0 10px rgba(255, 79, 163, 0.16);
}

body.theme-light {
  --bg-color: #fff1e5;
  --card-bg: rgba(255, 247, 238, 0.9);
  --card-border: rgba(255, 92, 166, 0.34);
  --accent-purple: #ff5ca6;
  --accent-neon: #ff3f9a;
  --accent-pink: #ff6fb4;
  --text-main: #8a3156;
  --text-muted: #a85776;
  --nav-bg: rgba(255, 242, 232, 0.94);
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 118, 184, 0.16), transparent 34%),
    linear-gradient(180deg, #fff4ea 0%, #ffefe5 48%, #fde8dc 100%);
}

body.theme-light .logo,
body.theme-light .catalog-logo {
  font-weight: 500;
  letter-spacing: 5px;
  background: linear-gradient(135deg, #ff9fd0 0%, #ff4fa3 52%, #b84470 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #ff4fa3;
  filter: drop-shadow(0 0 9px rgba(255, 79, 163, 0.46));
  text-shadow: 0 0 18px rgba(255, 79, 163, 0.32);
}

body.theme-light .catalog-logo {
  font-size: 32px;
}

body.theme-light .tagline,
body.theme-light .catalog-hero p {
  color: #9e4967;
  text-shadow: 0 0 9px rgba(255, 79, 163, 0.28);
}

body.theme-light h1,
body.theme-light h2,
body.theme-light h3,
body.theme-light .section-title,
body.theme-light .catalog-heading-row h2,
body.theme-light .npc-heading-row h2,
body.theme-light .premium-title-row h2,
body.theme-light .premium-section-title,
body.theme-light .settings-section-title {
  color: #ff4fa3;
  text-shadow: var(--lux-neon-text);
}

body.theme-light .btn-premium,
body.theme-light .btn-premium[data-subscription="general"],
body.theme-light .btn-premium[data-subscription="basic"],
body.theme-light .btn-premium[data-subscription="premium"] {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(255, 92, 166, 0.28);
  color: #9f3a61;
  text-shadow: var(--lux-neon-text);
  box-shadow: var(--lux-neon-box);
}

/* Setting worlds: isolated from the regular character and story catalog. */
/* Same frame as the NPC, character and story tabs of the catalog. */
.worlds-view {
  padding: 0 clamp(10px, 3vw, 18px) 88px;
}

.worlds-section-head,
.world-play-header,
.world-scene-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.worlds-heading .world-icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
}

.world-play-header h2 {
  margin: 4px 0 0;
  letter-spacing: 0;
}

.world-play-header span,
.world-card-copy > span,
.world-run-row small,
.worlds-section-head span {
  color: #82dce8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.world-icon-button,
.world-back-button {
  border: 1px solid rgba(130, 220, 232, 0.35);
  border-radius: 6px;
  background: rgba(14, 30, 38, 0.76);
  color: #eafcff;
}

.world-icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  font-size: 20px;
}

.worlds-status {
  min-height: 24px;
  color: #f2b5cb;
}

.worlds-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.world-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(11, 13, 25, 0.88);
}

/* World covers are authored in 3:4 and are shown whole. */
.world-card > img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
}

.world-author {
  color: rgba(244, 240, 251, 0.62);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.world-card-copy {
  display: grid;
  gap: 9px;
  padding: 16px;
}

.world-card-copy h3,
.world-detail h2,
.world-detail h3,
.worlds-section-head h3 {
  margin: 0;
  letter-spacing: 0;
}

.world-card-copy p,
.world-detail p {
  margin: 0;
  color: rgba(244, 240, 251, 0.76);
  line-height: 1.5;
}

.world-card-copy button,
.world-start-form button {
  min-height: 42px;
  border: 1px solid rgba(220, 158, 255, 0.44);
  border-radius: 6px;
  background: #8e39d6;
  color: white;
  font-weight: 750;
}

.worlds-section-head {
  margin: 34px 0 12px;
}

.world-runs-list {
  display: grid;
  gap: 8px;
}

.world-run-row {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
  text-align: left;
}

.world-run-cover,
.world-run-cover img {
  width: 48px;
  height: 48px;
  border-radius: 5px;
  object-fit: cover;
}

.world-run-row > span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.world-run-row strong,
.world-run-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.world-run-row em,
.world-play-state {
  color: #8ee8c1;
  font-size: 12px;
  font-style: normal;
}

.world-run-row em.is-complete,
.world-play-state.is-complete {
  color: #f1c76d;
}

.world-runs-link {
  display: block;
  margin: 28px auto 0;
  padding: 10px 16px;
  border: 1px solid rgba(130, 220, 232, 0.35);
  border-radius: 6px;
  background: rgba(14, 30, 38, 0.6);
  color: #82dce8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.world-runs-link[hidden] {
  display: none;
}

/* Cabinet → «Мои слоты» → «Миры». */
.cabinet-worlds-head {
  margin-top: 30px;
}

.cabinet-world-runs {
  display: grid;
  gap: 18px;
}

.cabinet-world-group {
  display: grid;
  gap: 8px;
}

.cabinet-world-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cabinet-world-title span {
  color: #82dce8;
  font-size: 12px;
  font-weight: 700;
}

.cabinet-world-new {
  min-height: 44px;
  border: 1px dashed rgba(130, 220, 232, 0.45);
  border-radius: 6px;
  background: rgba(14, 30, 38, 0.5);
  color: #82dce8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.cabinet-world-new:hover {
  background: rgba(31, 108, 121, 0.35);
}

.world-empty {
  grid-column: 1 / -1;
  padding: 28px 18px;
  border: 1px dashed rgba(255, 255, 255, 0.17);
  border-radius: 6px;
  color: rgba(244, 240, 251, 0.7);
  text-align: center;
}

.world-empty.compact {
  padding: 16px;
}

/* Styled confirmation dialog (plan switch and other important choices). */
.miti-confirm {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 16px;
}

.miti-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 2, 12, 0.72);
  backdrop-filter: blur(4px);
}

.miti-confirm-card {
  position: relative;
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
  padding: 22px 20px 18px;
  border: 1px solid rgba(192, 132, 252, 0.5);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(34, 16, 60, 0.98), rgba(14, 8, 28, 0.98));
  color: var(--text-main);
  box-shadow: var(--lux-neon-box);
}

.miti-confirm-card h3 {
  margin: 0 0 4px;
  font-size: 19px;
}

.miti-confirm-card p {
  margin: 0;
  color: rgba(244, 240, 251, 0.82);
  font-size: 14px;
  line-height: 1.5;
}

.miti-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.miti-confirm-actions button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

body.theme-light .miti-confirm-card {
  background: linear-gradient(180deg, #fff7fb, #ffeef6);
  border-color: rgba(255, 91, 168, 0.5);
}

body.theme-light .miti-confirm-card p {
  color: #5b2a36;
}

/* Lore offer and locked worlds: the catalog is visible, the run needs MiTi Lore. */
.world-lore-offer {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 22px 18px;
  border: 1px solid rgba(192, 132, 252, 0.42);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(168, 85, 247, 0.22), transparent 70%),
    rgba(12, 7, 26, 0.72);
  text-align: center;
  box-shadow: var(--lux-neon-box);
}

.world-lore-kicker {
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.world-lore-offer p {
  margin: 0;
  max-width: 420px;
  color: rgba(244, 240, 251, 0.82);
  line-height: 1.5;
}

.world-lore-cta {
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.world-card {
  position: relative;
}

.world-lock-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border: 1px solid rgba(192, 132, 252, 0.6);
  border-radius: 999px;
  background: rgba(12, 7, 26, 0.78);
  color: #f5d0fe;
  font-size: 12px;
  font-weight: 800;
}

.world-card.is-locked .world-card-copy button {
  background: rgba(8, 4, 18, 0.45);
  color: #f0abfc;
}

body.theme-light .world-lore-offer {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 91, 168, 0.16), transparent 70%),
    rgba(255, 249, 253, 0.82);
  border-color: rgba(255, 91, 168, 0.48);
}

body.theme-light .world-lore-offer p {
  color: #5b2a36;
}

body.theme-light .world-lore-kicker {
  color: #b0346e;
}

.world-back-button {
  min-height: 38px;
  margin-bottom: 16px;
  padding: 0 12px;
}

.world-detail-hero {
  display: grid;
  grid-template-columns: minmax(220px, 38%) 1fr;
  gap: 24px;
  align-items: center;
}

.world-detail-hero img {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  object-fit: cover;
}

.world-detail-hero > div,
.world-detail-section,
.world-start-form {
  display: grid;
  gap: 12px;
}

.world-detail-section {
  margin-top: 26px;
}

.world-cast-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.world-cast-list > div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-left: 2px solid #82dce8;
  background: rgba(255, 255, 255, 0.045);
}

.world-cast-list span {
  color: rgba(244, 240, 251, 0.68);
}

.world-start-form {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.world-avatar-heading,
.admin-world-toolbar,
.admin-world-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.world-avatar-heading > div,
.admin-world-toolbar > div,
.admin-world-editor-head > div {
  display: grid;
  gap: 4px;
}

.world-avatar-heading span,
.admin-world-toolbar span,
.admin-world-editor-head span {
  color: rgba(244, 240, 251, 0.66);
  font-size: 12px;
}

.world-avatar-heading output {
  color: #8ee8c1;
  font-size: 12px;
  font-weight: 700;
}

.world-avatar-heading output.is-over { color: #ff8ba9; }

.world-avatar-grid,
.admin-world-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.world-avatar-grid label,
.admin-world-fields label,
.admin-world-comment {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.world-avatar-grid textarea,
.admin-world-fields textarea,
.admin-world-comment textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: #151322;
  color: #fff;
  font: inherit;
}

.world-run-title-field { grid-column: 1 / -1; }
.world-avatar-note { font-size: 12px; }

.world-start-form label {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.world-start-form label > span {
  color: rgba(244, 240, 251, 0.68);
  font-size: 12px;
}

.world-start-form select,
.world-start-form input,
.world-composer textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: #151322;
  color: #fff;
  font: inherit;
}

.world-start-form select,
.world-start-form input {
  padding: 0 11px;
}

.world-start-form button {
  padding: 0 18px;
}

/* The run fills the screen under the site header; only the messages scroll, like the chat. */
.world-play-view {
  height: calc(100dvh - var(--world-play-top, 100px));
  min-height: 420px;
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 20px;
  flex-direction: column;
}

.world-mode-switch {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
}

.world-mode-switch span {
  margin-right: 4px;
  color: rgba(244, 240, 251, 0.6);
  font-size: 12px;
}

.world-mode-switch button {
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(244, 240, 251, 0.82);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.world-mode-switch button.active {
  border-color: rgba(196, 114, 244, 0.7);
  background: rgba(124, 58, 237, 0.35);
  color: #fff;
}

.world-play-view .world-chat-log {
  min-height: 0;
  overscroll-behavior: contain;
}

/* No bottom menu in a run, so no room kept for it. */
body.setting-play-mode {
  padding-bottom: 0;
}

body.setting-play-mode .bottom-nav {
  display: none;
}

.world-play-header {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.world-play-header > div {
  min-width: 0;
  flex: 1;
}

.world-play-header h2 {
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.world-scene-strip {
  justify-content: flex-start;
  flex-wrap: wrap;
  padding: 10px 0;
  color: rgba(244, 240, 251, 0.66);
  font-size: 12px;
}

.world-scene-strip span + span::before {
  content: "·";
  margin-right: 16px;
  color: #d8a6ff;
}

.world-chat-log {
  min-height: 360px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
}

.world-message {
  display: flex;
}

.world-message > div {
  max-width: min(78%, 680px);
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  line-height: 1.58;
  white-space: pre-wrap;
}

.world-message.user {
  justify-content: flex-end;
}

.world-message.user > div {
  border-color: rgba(130, 220, 232, 0.3);
  background: rgba(31, 108, 121, 0.28);
}

.world-message.is-pending > div {
  opacity: 0.7;
}

.world-typing > div {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.world-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: world-typing-dot 1.2s ease-in-out infinite;
}

.world-typing i:nth-child(2) { animation-delay: 0.2s; }
.world-typing i:nth-child(3) { animation-delay: 0.4s; }

@keyframes world-typing-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .world-typing i { animation: none; opacity: 0.7; }
}

.world-chat-error {
  margin-bottom: 8px;
  color: #ffabc3;
}

.world-composer {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.world-composer textarea {
  min-height: 48px;
  max-height: 150px;
  resize: vertical;
  padding: 12px;
}

.world-composer button {
  width: 44px;
  height: 44px;
  align-self: end;
  border: 0;
  border-radius: 6px;
  background: #8e39d6;
  color: #fff;
  font-size: 18px;
}

body.theme-light .world-card,
body.theme-light .world-run-row,
body.theme-light .world-cast-list > div,
body.theme-light .world-start-form select,
body.theme-light .world-start-form input,
body.theme-light .world-start-form textarea,
body.theme-light .world-composer textarea {
  border-color: rgba(123, 77, 139, 0.18);
  background: rgba(255, 255, 255, 0.8);
  color: #3e2749;
}

.admin-world-toolbar,
.admin-world-editor,
.admin-world-row {
  padding: 16px;
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: 8px;
  background: rgba(11, 13, 25, 0.72);
}

.admin-story-tabs {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(192, 132, 252, 0.22);
  border-radius: 7px;
  background: rgba(8, 16, 34, 0.68);
}

.admin-story-tabs button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
}

.admin-story-tabs button[aria-selected="true"] {
  background: #8e39d6;
  color: #fff;
}

.admin-story-section {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.admin-story-section.admin-db-catalog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.admin-world-toolbar button,
.admin-world-actions button,
.admin-world-editor-actions button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(216, 166, 255, 0.42);
  border-radius: 6px;
  background: rgba(142, 57, 214, 0.24);
  color: #fff;
  font-weight: 700;
}

.admin-world-actions button.admin-world-publish {
  border-color: rgba(134, 239, 172, 0.6);
  background: rgba(22, 101, 52, 0.45);
}

.admin-world-list { display: grid; gap: 10px; }
.admin-world-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.admin-world-row-copy { min-width: 0; display: grid; gap: 4px; }
.admin-world-row-cover {
  width: 88px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(142, 57, 214, 0.16);
  color: #d8a6ff;
  font-weight: 800;
}
.admin-world-row-cover img,
.admin-world-cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-world-row span,
.admin-world-row small { color: rgba(244, 240, 251, 0.66); }
.admin-world-actions,
.admin-world-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-world-editor { display: grid; gap: 16px; }
.admin-world-editor[hidden] { display: none; }
.admin-world-wide { grid-column: 1 / -1; }
.admin-world-cover-editor {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.admin-world-cover-preview {
  width: 160px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(216, 166, 255, 0.4);
  border-radius: 6px;
  color: rgba(244, 240, 251, 0.66);
  text-align: center;
}
.admin-world-fields input {
  width: 100%; min-height: 42px; padding: 0 11px; border: 1px solid rgba(255,255,255,.14);
  border-radius: 6px; background: #151322; color: #fff; font: inherit;
}
.admin-world-json { min-height: 360px !important; font-family: Consolas, monospace !important; font-size: 12px !important; }
.admin-world-source pre { max-height: 280px; overflow: auto; white-space: pre-wrap; padding: 12px; background: #090713; }
.admin-world-source li { margin: 6px 0 0 18px; color: #f4bdd0; }

body.theme-light .world-card-copy p,
body.theme-light .world-detail p,
body.theme-light .world-cast-list span {
  color: rgba(68, 42, 77, 0.72);
}

@media (max-width: 760px) {
  .worlds-grid,
  .world-cast-list,
  .world-avatar-grid,
  .admin-world-fields,
  .world-detail-hero {
    grid-template-columns: 1fr;
  }

  /* Phone: cover on the left, text on the right, so a 3:4 cover stays compact. */
  .world-card:not(.world-lore-offer) {
    display: grid;
    grid-template-columns: minmax(118px, 40%) minmax(0, 1fr);
    align-items: stretch;
  }

  .world-card > img {
    height: 100%;
    min-height: 100%;
  }

  .world-card-copy {
    align-content: center;
    padding: 14px;
  }

  .world-detail-hero img {
    width: min(100%, 320px);
    justify-self: center;
  }

  .admin-world-row,
  .admin-world-toolbar { align-items: stretch; flex-direction: column; }

  .admin-story-tabs,
  .admin-world-cover-editor { width: 100%; grid-template-columns: 1fr; }

  .admin-story-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-story-section.admin-db-catalog-grid { grid-template-columns: 1fr; }
  .admin-world-row { grid-template-columns: 72px minmax(0, 1fr); }
  .admin-world-actions { grid-column: 1 / -1; }
  .admin-world-row-cover { width: 72px; }
  .admin-world-cover-preview { width: min(100%, 240px); }

  .world-detail-hero img {
    max-height: 340px;
  }

  .worlds-section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .world-run-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .world-run-row em {
    grid-column: 2;
  }

  .world-play-view {
    padding: 12px;
  }

  .world-message > div {
    max-width: 90%;
  }
}

/* Desktop and tablet administrator workspace. */
body.admin-mode {
  --admin-surface: rgba(19, 13, 40, 0.94);
  --admin-surface-soft: rgba(29, 20, 57, 0.82);
  --admin-border: rgba(177, 117, 255, 0.26);
  --admin-muted: rgba(225, 207, 255, 0.66);
  padding-bottom: 0;
  background:
    linear-gradient(145deg, rgba(7, 5, 20, 0.98), rgba(17, 10, 35, 0.96)),
    var(--bg-color);
}

body.admin-mode > .glow-bg,
body.admin-mode > .glow-bg-secondary,
body.admin-mode .app-container > .header,
body.admin-mode .app-container > .sub-nav,
body.admin-mode .bottom-nav {
  display: none !important;
}

body.admin-mode .app-container {
  width: 100%;
  max-width: 1440px;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
}

body.admin-mode #main-view {
  min-height: 100vh;
  min-height: 100dvh;
}

body.admin-mode .admin-view {
  padding: 0;
}

.admin-workspace {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 0;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 16px 18px;
  border-right: 1px solid var(--admin-border);
  background:
    linear-gradient(180deg, rgba(25, 17, 50, 0.97), rgba(10, 8, 25, 0.98));
  box-shadow: 12px 0 34px rgba(0, 0, 0, 0.16);
}

.admin-sidebar-brand {
  min-height: 72px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  border-bottom: 1px solid rgba(192, 132, 252, 0.18);
}

.admin-sidebar-brand strong {
  color: #fff;
  font-size: 31px;
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: 0 0 10px rgba(192, 132, 252, 0.82), 0 0 24px rgba(236, 72, 153, 0.38);
}

.admin-sidebar-brand span {
  color: rgba(230, 212, 255, 0.62);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.admin-sidebar-nav {
  display: grid;
  gap: 5px;
}

.admin-sidebar-nav button,
.admin-sidebar-exit {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(232, 217, 255, 0.76);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.admin-sidebar-nav button > span,
.admin-sidebar-exit > span {
  color: #c084fc;
  font-size: 18px;
  text-align: center;
}

.admin-sidebar-nav button small {
  padding: 3px 5px;
  border-radius: 999px;
  background: rgba(236, 72, 153, 0.18);
  color: #ff8bc7;
  font-size: 8px;
  font-weight: 800;
}

.admin-sidebar-nav button:hover,
.admin-sidebar-nav button:focus-visible,
.admin-sidebar-nav button.is-active {
  border-color: rgba(192, 132, 252, 0.32);
  background: linear-gradient(135deg, rgba(122, 54, 238, 0.64), rgba(91, 43, 186, 0.78));
  color: #fff;
  outline: none;
}

.admin-sidebar-divider {
  height: 1px;
  margin: 8px 0;
  background: rgba(192, 132, 252, 0.18);
}

.admin-sidebar-exit {
  margin-top: auto;
  border-color: rgba(192, 132, 252, 0.25);
  background: rgba(255, 255, 255, 0.025);
}

.admin-workspace-main {
  min-width: 0;
  padding: 18px 22px 34px;
}

body.admin-mode .admin-hero {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(39, 26, 74, 0.9), rgba(22, 16, 45, 0.9));
  box-shadow: none;
}

body.admin-mode .admin-hero h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

body.admin-mode .admin-kicker {
  margin-bottom: 4px;
  font-size: 9px;
  letter-spacing: 0.16em;
}

body.admin-mode .admin-top-actions {
  grid-column: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

body.admin-mode .admin-top-actions button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 11px;
}

.admin-profile-chip {
  min-width: 168px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px;
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.admin-profile-chip > b {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #8038e8, #e5489b);
  color: #fff;
}

.admin-profile-chip span,
.admin-profile-chip strong,
.admin-profile-chip small {
  display: block;
  min-height: 0;
}

.admin-profile-chip strong {
  color: #fff;
  font-size: 11px;
}

.admin-profile-chip small {
  margin-top: 2px;
  color: #81e6a5;
  font-size: 9px;
}

body.admin-mode .admin-stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

body.admin-mode .admin-stat-card {
  min-height: 94px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  column-gap: 9px;
  padding: 13px;
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(43, 30, 82, 0.88), rgba(27, 20, 54, 0.9));
}

body.admin-mode .admin-stat-card > span:not(.admin-stat-icon) {
  min-height: 0;
  align-self: end;
  font-size: 10px;
}

body.admin-mode .admin-stat-card .admin-stat-icon {
  grid-row: 1 / 4;
  width: 34px;
  height: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 8px;
  background: rgba(152, 81, 238, 0.22);
  color: #d4a7ff;
  font-size: 19px;
}

body.admin-mode .admin-stat-card strong {
  margin: 1px 0;
  font-size: 25px;
  line-height: 1;
}

body.admin-mode .admin-stat-card small {
  color: rgba(139, 232, 173, 0.76);
  font-size: 8px;
}

.admin-dashboard-section,
body.admin-mode .admin-runtime-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--admin-border);
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(31, 22, 60, 0.9), rgba(20, 15, 41, 0.92));
}

.admin-section-heading {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.admin-section-heading h3 {
  margin: 0;
  color: #f6edff;
  font-size: 15px;
}

.admin-section-heading p {
  margin-top: 3px;
  color: var(--admin-muted);
  font-size: 9px;
}

.admin-section-heading button {
  border: 0;
  background: transparent;
  color: #c084fc;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

body.admin-mode .admin-control-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 0;
}

body.admin-mode .admin-control-card {
  min-height: 48px;
  grid-template-columns: 26px minmax(0, 1fr);
  grid-template-rows: 1fr;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(126, 53, 232, 0.58), rgba(75, 43, 158, 0.72));
}

body.admin-mode .admin-control-card:first-child {
  background: linear-gradient(135deg, rgba(232, 72, 158, 0.82), rgba(142, 61, 224, 0.82));
}

body.admin-mode .admin-control-card > span {
  grid-row: auto;
  width: 24px;
  height: 24px;
  border-radius: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 300;
}

body.admin-mode .admin-control-card strong {
  font-size: 10px;
  line-height: 1.25;
}

.admin-dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 14px;
}

.admin-coming-badge {
  padding: 5px 8px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.09);
  color: #f6c96a;
  font-size: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-placeholder-state {
  min-height: 90px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 13px;
  border: 1px dashed rgba(192, 132, 252, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.022);
}

.admin-placeholder-state > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(168, 85, 247, 0.16);
  color: #c084fc;
  font-size: 20px;
}

.admin-placeholder-state strong {
  color: #f3e8ff;
  font-size: 11px;
}

.admin-placeholder-state p {
  margin-top: 5px;
  color: var(--admin-muted);
  font-size: 9px;
  line-height: 1.4;
}

.admin-operation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.admin-operation-grid article,
.admin-operation-grid button {
  min-height: 59px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 9px;
  border: 1px solid rgba(192, 132, 252, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.028);
  color: inherit;
  text-align: left;
}

.admin-operation-grid span {
  color: var(--admin-muted);
  font-size: 8px;
  font-weight: 700;
}

.admin-operation-grid strong {
  color: #f3e8ff;
  font-size: 15px;
}

.admin-operation-grid .is-ok strong {
  color: #70d99a;
}

.admin-operation-grid .is-bad strong {
  color: #ff7da8;
}

body.admin-mode .admin-runtime-panel {
  scroll-margin-top: 14px;
}

body.admin-mode .admin-runtime-header h3 {
  font-size: 16px;
}

body.admin-mode .admin-runtime-header button,
body.admin-mode .admin-plan-card button {
  min-height: 34px;
  border-radius: 8px;
  font-size: 10px;
}

body.admin-mode .admin-log-list {
  max-height: 310px;
  overflow: auto;
}

body.admin-mode .admin-log-row {
  grid-template-columns: 72px minmax(0, 1fr) minmax(80px, auto);
  border-radius: 7px;
}

.admin-workspace-database .admin-db-panel {
  min-width: 0;
  margin: 18px 22px 34px;
  padding: 16px;
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(31, 22, 60, 0.94), rgba(20, 15, 41, 0.96));
  box-shadow: none;
}

body.admin-mode .admin-db-header {
  min-height: 58px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(192, 132, 252, 0.16);
}

body.admin-mode .admin-db-header h2 {
  font-size: 20px;
  letter-spacing: 0;
}

body.admin-mode .admin-db-header span {
  font-size: 10px;
}

body.admin-mode .admin-db-list.admin-db-catalog-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body.admin-mode .admin-db-card,
body.admin-mode .admin-user-card,
body.admin-mode .admin-user-search,
body.admin-mode .admin-db-empty,
body.admin-mode .admin-db-loading {
  background: rgba(11, 9, 28, 0.48);
  border-color: rgba(192, 132, 252, 0.2);
  box-shadow: none;
}

body.admin-mode .create-character-view,
body.admin-mode .admin-media-view {
  width: min(1100px, 100%);
  margin: 0 auto;
}

body.admin-mode.theme-light .admin-sidebar,
body.admin-mode.theme-light .admin-hero,
body.admin-mode.theme-light .admin-dashboard-section,
body.admin-mode.theme-light .admin-runtime-panel,
body.admin-mode.theme-light .admin-db-panel {
  color: #f3e8ff;
}

@media (max-width: 1050px) {
  .admin-workspace {
    grid-template-columns: 182px minmax(0, 1fr);
  }

  .admin-sidebar {
    padding-inline: 11px;
  }

  .admin-sidebar-nav button,
  .admin-sidebar-exit {
    padding-inline: 8px;
    font-size: 10px;
  }

  .admin-workspace-main,
  .admin-workspace-database .admin-db-panel {
    padding-inline: 14px;
    margin-inline: 0;
  }

  body.admin-mode .admin-control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-dashboard-columns {
    grid-template-columns: 1fr;
  }

  body.admin-mode .admin-db-list.admin-db-catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .admin-workspace {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: sticky;
    height: auto;
    padding: 8px 10px;
    gap: 7px;
    border-right: 0;
    border-bottom: 1px solid var(--admin-border);
  }

  .admin-sidebar-brand,
  .admin-sidebar-divider,
  .admin-sidebar-exit {
    display: none;
  }

  .admin-sidebar-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
  }

  .admin-sidebar-nav button {
    width: auto;
    min-width: max-content;
    grid-template-columns: 22px auto auto;
    min-height: 38px;
    padding-inline: 9px;
  }

  body.admin-mode .admin-hero {
    grid-template-columns: 1fr;
  }

  body.admin-mode .admin-top-actions {
    justify-content: stretch;
  }

  .admin-profile-chip {
    flex: 1;
  }

  body.admin-mode .admin-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.admin-mode .admin-control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.admin-mode .admin-db-list.admin-db-catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .admin-workspace-main {
    padding: 10px 10px 26px;
  }

  body.admin-mode .admin-top-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .admin-profile-chip {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  body.admin-mode .admin-runtime-grid,
  body.admin-mode .admin-plan-grid {
    grid-template-columns: 1fr;
  }
}

body.theme-light .btn-notification {
  background: rgba(255, 244, 236, 0.88);
  border-color: rgba(255, 92, 166, 0.3);
  color: #ff3f9a;
  box-shadow: 0 0 16px rgba(255, 79, 163, 0.2);
}

body.theme-light .story-filter-btn,
body.theme-light .npc-sort-btn {
  background: rgba(190, 143, 160, 0.28);
  border-color: rgba(255, 92, 166, 0.22);
  color: #9b4967;
  text-shadow: var(--lux-neon-text);
}

body.theme-light .theme-switcher button.active {
  color: #ff3f9a;
  background: rgba(255, 248, 242, 0.34);
  border-color: rgba(255, 63, 154, 0.72);
  text-shadow: var(--lux-neon-text);
  box-shadow: var(--lux-neon-box);
  filter: var(--lux-neon-icon);
}

body.theme-light .catalog-heading-row span,
body.theme-light .story-card-overlay small,
body.theme-light .catalog-card-overlay span,
body.theme-light .npc-card-overlay span,
body.theme-light .saved-character-body span,
body.theme-light .premium-benefits small,
body.theme-light .premium-plan-card li,
body.theme-light .premium-footer-links p,
body.theme-light .premium-footer-links button {
  color: #9e4967;
}

body.theme-light .catalog-card,
body.theme-light .npc-card,
body.theme-light .story-card,
body.theme-light .saved-character-card {
  background: #130915;
  border-color: rgba(255, 92, 166, 0.42);
  box-shadow:
    0 12px 24px rgba(61, 25, 36, 0.24),
    0 0 18px rgba(255, 79, 163, 0.14);
}

body.theme-light .npc-card img,
body.theme-light .story-card img,
body.theme-light .saved-character-card img {
  filter: brightness(0.72) contrast(1.08) saturate(1.08);
}

body.theme-light .npc-card::after,
body.theme-light .story-card::after,
body.theme-light .saved-character-card::after {
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 2, 12, 0.1) 0%, rgba(6, 2, 12, 0.2) 36%, rgba(6, 2, 12, 0.92) 100%),
    radial-gradient(circle at 50% 100%, rgba(255, 63, 154, 0.2), transparent 48%);
}

body.theme-light .catalog-card img {
  filter: none;
}

body.theme-light .catalog-card::after {
  inset: auto 0 0;
  height: 38%;
  background: linear-gradient(180deg, rgba(103, 55, 42, 0), rgba(103, 55, 42, 0.28) 58%, rgba(103, 55, 42, 0.56));
}

body.theme-light .catalog-card-overlay,
body.theme-light .npc-card-overlay,
body.theme-light .story-card-overlay {
  background: transparent;
}

body.theme-light .catalog-card-overlay strong,
body.theme-light .npc-card-overlay strong,
body.theme-light .story-card-overlay strong,
body.theme-light .saved-character-body strong {
  color: #ff9fd0;
  text-shadow:
    0 0 8px rgba(255, 63, 154, 0.85),
    0 2px 8px rgba(0, 0, 0, 0.86);
}

body.theme-light .catalog-card-overlay span,
body.theme-light .npc-card-overlay span,
body.theme-light .story-card-overlay small,
body.theme-light .saved-character-body span {
  color: #ffd7e8;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.86);
}

body.theme-light .catalog-card.active,
body.theme-light .npc-card.active,
body.theme-light .story-card.active {
  border-color: #ff3f9a;
  box-shadow:
    0 0 24px rgba(255, 63, 154, 0.5),
    0 16px 28px rgba(61, 25, 36, 0.26);
}

body.theme-light .npc-badge,
body.theme-light .story-badge {
  background: rgba(255, 104, 174, 0.86);
  color: #fff6fb;
  box-shadow: 0 0 12px rgba(255, 63, 154, 0.38);
}

body.theme-light .npc-info,
body.theme-light .story-info,
body.theme-light .catalog-favorite,
body.theme-light .story-card-action,
body.theme-light .npc-add {
  background: rgba(34, 13, 29, 0.66);
  border-color: rgba(255, 159, 208, 0.7);
  color: #ffd7e8;
  box-shadow: 0 0 12px rgba(255, 63, 154, 0.32);
}

body.theme-light .section-container,
body.theme-light .gameplay-section,
body.theme-light .character-sheet-panel,
body.theme-light .story-detail,
body.theme-light .story-feature-grid article,
body.theme-light .story-tip,
body.theme-light .settings-profile-panel,
body.theme-light .settings-row,
body.theme-light .premium-panel,
body.theme-light .subscription-panel,
body.theme-light .subscription-status-card,
body.theme-light .premium-benefits article,
body.theme-light .premium-plan-card,
body.theme-light .admin-hero,
body.theme-light .admin-stat-card,
body.theme-light .admin-control-card {
  background:
    linear-gradient(135deg, rgba(255, 246, 239, 0.92), rgba(245, 218, 207, 0.82));
  border-color: rgba(255, 92, 166, 0.28);
  color: #7f2d4f;
  box-shadow:
    0 16px 34px rgba(154, 79, 103, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

body.theme-light .premium-panel {
  background:
    radial-gradient(circle at 82% 0%, rgba(255, 79, 163, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(255, 246, 239, 0.96), rgba(244, 221, 211, 0.9));
}

body.theme-light .premium-hero {
  background: #170817;
  border-color: rgba(255, 92, 166, 0.38);
  box-shadow:
    0 18px 34px rgba(61, 25, 36, 0.2),
    0 0 24px rgba(255, 79, 163, 0.18);
}

body.theme-light .premium-hero img {
  filter: brightness(0.82) contrast(1.08) saturate(1.08);
}

body.theme-light .premium-hero::after {
  inset: 0;
  background:
    linear-gradient(180deg, rgba(15, 5, 18, 0.02), rgba(15, 5, 18, 0.18) 42%, rgba(15, 5, 18, 0.78) 100%),
    radial-gradient(circle at 72% 32%, rgba(255, 79, 163, 0.16), transparent 38%);
}

body.theme-light .premium-hero-content strong {
  color: #ffb0d7;
  text-shadow:
    0 0 12px rgba(255, 63, 154, 0.85),
    0 2px 9px rgba(0, 0, 0, 0.86);
}

body.theme-light .premium-hero-content span {
  color: #ffe1ee;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.82);
}

body.theme-light .premium-activate,
body.theme-light .premium-select-plan,
body.theme-light .catalog-create-cta,
body.theme-light .saved-create-btn {
  background: linear-gradient(135deg, #ff7fbd, #b74577);
  border-color: rgba(255, 159, 208, 0.72);
  color: #fff8fb;
  text-shadow: var(--lux-neon-text);
  box-shadow: var(--lux-neon-box);
}

body.theme-light .premium-benefits span,
body.theme-light .premium-price-row strong,
body.theme-light .settings-row > span:first-child {
  color: #ff3f9a;
  text-shadow: 0 0 10px rgba(255, 79, 163, 0.28);
}

body.theme-light .premium-benefits b,
body.theme-light .premium-plan-card h4,
body.theme-light .premium-plan-card ul,
body.theme-light .story-detail-copy h1,
body.theme-light .story-meta-list b,
body.theme-light .story-feature-grid b,
body.theme-light .story-tip b {
  color: #8a3156;
  text-shadow: 0 0 9px rgba(255, 79, 163, 0.18);
}

body.theme-light .premium-price-row small,
body.theme-light .premium-price-row del,
body.theme-light .premium-plan-note,
body.theme-light .story-detail-copy p,
body.theme-light .story-info-block p,
body.theme-light .story-tip p,
body.theme-light .story-feature-grid p {
  color: #9e4967;
}

body:not(.theme-light) .header,
body:not(.theme-light).catalog-mode .header {
  background: rgba(12, 7, 26, 0.7);
  border-bottom: 1px solid var(--card-border);
  padding: 16px 20px;
}

body:not(.theme-light) .logo,
body:not(.theme-light).catalog-mode .logo {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0;
  background: linear-gradient(135deg, #ffffff 0%, #c084fc 60%, #ec4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #f3e8ff;
  filter: drop-shadow(0 0 11px rgba(192, 132, 252, 0.78));
  text-shadow:
    0 0 12px rgba(192, 132, 252, 0.62),
    0 0 22px rgba(147, 51, 234, 0.42);
}

body:not(.theme-light) .tagline,
body:not(.theme-light).catalog-mode .tagline {
  color: var(--text-muted);
  letter-spacing: 1.2px;
}

body.theme-light .logo,
body.theme-light.catalog-mode .logo {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0;
  background: linear-gradient(135deg, #ff8fc8 0%, #ff4fa3 58%, #b84470 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #ff4fa3;
  filter: drop-shadow(0 0 12px rgba(255, 79, 163, 0.64));
  text-shadow:
    0 0 12px rgba(255, 79, 163, 0.5),
    0 0 24px rgba(255, 111, 180, 0.34);
}

body.theme-light .tagline,
body.theme-light.catalog-mode .tagline {
  color: #9e4967;
  letter-spacing: 1.2px;
  text-shadow: 0 0 9px rgba(255, 79, 163, 0.24);
}

body.theme-light.catalog-mode .header {
  padding: 16px 20px;
  background: rgba(255, 239, 226, 0.9);
}

@media (max-width: 430px) {
  .settings-view {
    padding: 12px;
  }

  .settings-profile-top {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .settings-profile-info {
    width: 100%;
  }

  .settings-name-input {
    text-align: center;
  }

  .settings-name-row,
  .settings-username-row {
    justify-content: center;
    margin-inline: auto;
  }

  /* A spacer as wide as the ✓ button keeps the centered name truly centered. */
  .settings-name-row::before {
    content: "";
    flex: 0 0 34px;
  }

  .settings-username-field {
    justify-content: center;
  }

  .achievement-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .settings-row {
    font-size: 16px;
    grid-template-columns: 34px 1fr auto auto;
  }
}

@media (max-width: 430px) {
  .premium-view {
    padding: 12px;
  }

  .premium-panel {
    padding: 12px;
  }

  .premium-title-row {
    grid-template-columns: 38px 1fr 38px;
  }

  .premium-title-row h2 {
    font-size: 16px;
  }

  .premium-hero-content {
    grid-template-columns: 1fr;
  }

  .premium-activate {
    width: 100%;
  }

  .premium-benefits {
    grid-template-columns: repeat(2, 1fr);
  }

  .premium-plans,
  .premium-footer-links {
    grid-template-columns: 1fr;
  }

  .premium-plan-card ul {
    min-height: 0;
  }

  .premium-footer-links div {
    justify-items: start;
  }
}

.sheet-open {
  overflow: hidden;
}

.character-sheet {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: none;
}

.character-sheet.open {
  display: block;
}

.character-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 0, 8, 0.76);
  backdrop-filter: blur(12px);
}

.character-sheet-panel {
  position: absolute;
  inset: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  max-width: 480px;
  margin: 0 auto;
  border: 1px solid rgba(168, 85, 247, 0.42);
  border-radius: 18px;
  background: rgba(5, 7, 18, 0.96);
  box-shadow: 0 0 34px rgba(147, 51, 234, 0.34);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sheet-topbar {
  min-height: 54px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(168, 85, 247, 0.26);
  background: rgba(9, 13, 30, 0.72);
}

.sheet-close,
.sheet-x {
  border: none;
  background: transparent;
  color: var(--accent-neon);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.sheet-close {
  font-size: 42px;
  line-height: 1;
}

.sheet-x {
  font-size: 28px;
}

.sheet-tabs {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  color: rgba(243, 232, 255, 0.62);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.sheet-tabs span {
  min-width: 132px;
  padding: 12px 18px;
  border-bottom: 2px solid transparent;
}

.sheet-tabs .active {
  color: #fff;
  border-bottom-color: var(--accent-pink);
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.65);
}

.sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 96px;
}

.sheet-hero {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr;
  gap: 16px;
  align-items: start;
}

.sheet-identity h2 {
  color: #fff;
  font-size: 38px;
  line-height: 1;
  font-weight: 700;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.28);
  margin: 8px 0 18px;
}

.sheet-identity h2::after {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 12px;
  border-radius: 50%;
  background: var(--accent-purple);
  box-shadow: 0 0 10px var(--accent-purple);
  vertical-align: middle;
}

.sheet-identity p {
  color: rgba(243, 232, 255, 0.86);
  font-size: 13px;
  line-height: 1.5;
}

.sheet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.sheet-tags span {
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 10px;
  background: rgba(147, 51, 234, 0.12);
  color: rgba(243, 232, 255, 0.86);
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.sheet-identity blockquote {
  margin: 0;
  border: 1px solid rgba(168, 85, 247, 0.24);
  border-radius: 12px;
  background: rgba(10, 16, 32, 0.68);
  color: rgba(243, 232, 255, 0.88);
  padding: 18px;
  font-size: 14px;
  line-height: 1.55;
}

.sheet-identity blockquote::before {
  content: "“";
  display: block;
  color: var(--accent-purple);
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
}

.sheet-portrait-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(168, 85, 247, 0.42);
  background: rgba(12, 7, 26, 0.8);
}

.sheet-portrait-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sheet-heart {
  position: absolute;
  top: 12px;
  right: 14px;
  color: #fff;
  font-size: 34px;
  line-height: 1;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
}

.sheet-section {
  margin-top: 20px;
}

.sheet-section h3,
.sheet-card h3 {
  color: var(--accent-neon);
  font-size: 16px;
  letter-spacing: 0.8px;
  font-weight: 700;
  margin-bottom: 12px;
}

.sheet-section p {
  color: rgba(243, 232, 255, 0.86);
  font-size: 14px;
  line-height: 1.65;
}

.sheet-lore-mode {
  padding: 14px;
  border: 1px solid rgba(192, 132, 252, 0.34);
  border-radius: 12px;
  background: rgba(147, 51, 234, 0.1);
}

.sheet-lore-mode[hidden] {
  display: none;
}

.sheet-lore-mode > p {
  margin: -4px 0 10px;
  font-size: 12px;
}

.lore-mode-control {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lore-mode-control .segment-btn {
  min-width: 0;
  padding: 10px 6px;
  font-size: 10px;
}

.sheet-two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.sheet-card {
  border: 1px solid rgba(168, 85, 247, 0.24);
  border-radius: 14px;
  background: rgba(9, 15, 32, 0.68);
  padding: 14px;
}

.sheet-stat {
  display: grid;
  grid-template-columns: minmax(78px, 0.8fr) 1fr 40px;
  align-items: center;
  gap: 10px;
  color: rgba(243, 232, 255, 0.86);
  font-size: 12px;
  margin: 12px 0;
}

.sheet-stat-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(39, 43, 70, 0.95);
  overflow: hidden;
}

.sheet-stat-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-neon));
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.8);
}

.sheet-stat b {
  color: #fff;
  text-align: right;
}

.sheet-preferences {
  display: grid;
  gap: 12px;
}

.sheet-preferences div {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sheet-preferences div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sheet-preferences b {
  color: #fff;
  font-size: 12px;
}

.sheet-preferences span {
  color: rgba(243, 232, 255, 0.72);
  font-size: 12px;
  line-height: 1.35;
}

.sheet-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px 16px;
  background: linear-gradient(180deg, rgba(5, 7, 18, 0), rgba(5, 7, 18, 0.98) 35%);
}

.sheet-chat-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #6d28ff, rgba(147, 51, 234, 0.72));
  color: #fff;
  padding: 15px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
  box-shadow: 0 0 24px rgba(147, 51, 234, 0.65);
  cursor: pointer;
}

@media (max-width: 430px) {
  .character-sheet-panel {
    inset: 8px;
  }

  .sheet-content {
    padding: 14px 14px 92px;
  }

  .sheet-hero {
    grid-template-columns: 1fr;
  }

  .sheet-portrait-wrap {
    order: -1;
    max-height: 430px;
  }

  .sheet-two-columns {
    grid-template-columns: 1fr;
  }

  .story-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 8px;
  }

  .story-card-overlay strong {
    font-size: 13px;
  }

  .story-card-overlay small {
    font-size: 7px;
  }

  .story-detail-hero,
  .story-info-block,
  .story-feature-grid,
  .story-actions {
    grid-template-columns: 1fr;
  }

  .story-detail-hero {
    min-height: 0;
  }

  .story-detail-hero::after {
    background: linear-gradient(180deg, rgba(3, 7, 18, 0.92), rgba(3, 7, 18, 0.68), rgba(3, 7, 18, 0.96));
  }

  .story-detail-copy h1 {
    font-size: 34px;
  }

  .story-detail-hero img {
    height: 300px;
  }

  .sheet-identity h2 {
    font-size: 34px;
  }
}

@media (max-width: 370px) {
  .catalog-grid,
  .npc-grid,
  .story-grid {
    gap: 10px 8px;
  }

  .catalog-card-overlay strong,
  .npc-card-overlay strong,
  .story-card-overlay strong {
    font-size: 14px;
  }

  .catalog-card-overlay span,
  .npc-card-overlay span,
  .story-card-overlay small {
    font-size: 7px;
  }

  .npc-badge {
    font-size: 7px;
    padding: 4px 6px;
  }
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: calc(48px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
  border-radius: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  position: relative;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 9px;
  font-weight: 700;
  gap: 2px;
  transition: all 0.2s ease;
}

.nav-new-indicator {
  position: absolute;
  top: -1px;
  right: 19px;
  width: 13px;
  height: 13px;
  border: 1px solid rgba(255, 235, 255, 0.72);
  border-radius: 50%;
  background: linear-gradient(135deg, #f9a8d4, #c084fc);
  color: #1a0827;
  box-shadow:
    0 0 10px rgba(236, 72, 153, 0.58),
    0 0 16px rgba(192, 132, 252, 0.34);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.nav-item.has-new .nav-new-indicator {
  display: flex;
}

.nav-item.active {
  color: var(--accent-neon);
  text-shadow: var(--lux-neon-text);
  filter: var(--lux-neon-icon);
}

body.theme-light .bottom-nav {
  background: linear-gradient(180deg, rgba(255, 249, 253, 0.98), rgba(255, 239, 248, 0.98));
  border-top: 1px solid rgba(255, 145, 196, 0.38);
  box-shadow:
    0 -8px 20px rgba(154, 79, 103, 0.1),
    0 -1px 0 rgba(255, 255, 255, 0.76);
}

body.theme-light .nav-item {
  color: #8d7890;
  text-shadow: none;
}

body.theme-light .nav-item.active {
  color: #ff4fa3;
  text-shadow: var(--lux-neon-text);
  filter: var(--lux-neon-icon);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--accent-neon);
  box-shadow: 0 0 15px rgba(192, 132, 252, 0.5);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  animation: slideDown 0.3s ease-out forwards;
  opacity: 0;
  transform: translateY(-20px);
}

.asset-disclaimer-toast {
  width: min(360px, calc(100vw - 32px));
  align-self: flex-end;
  position: relative;
  padding: 14px 42px 14px 16px;
  line-height: 1.35;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  pointer-events: auto;
}

.toast-container.asset-disclaimer-zone {
  left: auto;
  right: 16px;
  transform: none;
  align-items: flex-end;
}

.asset-disclaimer-close {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: currentColor;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.asset-disclaimer-close:active {
  transform: scale(0.96);
}

@keyframes slideDown {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.personality-card.active,
.catalog-card.active,
.npc-card.active,
.story-card.active,
.catalog-card.selected,
.npc-card.selected,
.saved-character-card.selected {
  background: transparent;
  outline: 1px solid var(--accent-neon);
  outline-offset: 0;
  box-shadow:
    0 0 0 1px rgba(192, 132, 252, 0.22),
    0 0 22px rgba(192, 132, 252, 0.42);
}

body.theme-light .nav-new-indicator {
  border-color: rgba(255, 255, 255, 0.9);
  background: linear-gradient(135deg, #ff8bc7, #ff4fa3);
  color: #fff8fb;
  box-shadow:
    0 0 10px rgba(255, 63, 154, 0.48),
    0 2px 8px rgba(126, 48, 78, 0.22);
}

body.theme-light .personality-card.active,
body.theme-light .catalog-card.active,
body.theme-light .npc-card.active,
body.theme-light .story-card.active,
body.theme-light .catalog-card.selected,
body.theme-light .npc-card.selected,
body.theme-light .saved-character-card.selected {
  background: transparent;
  outline: 1px solid rgba(255, 63, 154, 0.72);
  box-shadow:
    0 0 0 1px rgba(255, 63, 154, 0.22),
    0 0 22px rgba(255, 63, 154, 0.38);
}

body.theme-light .catalog-edit,
body.theme-light .catalog-delete,
body.theme-light .npc-edit {
  background:
    radial-gradient(circle at 45% 30%, rgba(255, 255, 255, 0.82), transparent 36%),
    linear-gradient(145deg, rgba(255, 130, 190, 0.96), rgba(173, 75, 126, 0.92));
  border-color: rgba(255, 255, 255, 0.78);
  color: #fff;
  text-shadow:
    0 0 8px rgba(255, 91, 168, 0.5),
    0 0 16px rgba(201, 77, 146, 0.36);
  box-shadow:
    0 0 0 1px rgba(255, 63, 154, 0.18),
    0 0 16px rgba(255, 91, 168, 0.28),
    0 0 22px rgba(255, 63, 154, 0.4),
    0 10px 20px rgba(126, 62, 95, 0.2);
}

body.theme-light .character-sheet-panel {
  background:
    radial-gradient(circle at 70% 0%, rgba(255, 111, 181, 0.12), transparent 36%),
    linear-gradient(180deg, rgba(255, 247, 241, 0.98), rgba(241, 222, 212, 0.96));
  color: #5b2a36;
}

body.theme-light .character-sheet-panel * {
  color: #5b2a36;
}

body.theme-light .sheet-topbar,
body.theme-light .sheet-card,
body.theme-light .sheet-identity blockquote,
body.theme-light .sheet-tags span,
body.theme-light .sheet-lore-mode {
  background: rgba(255, 248, 242, 0.78);
  border-color: rgba(255, 63, 154, 0.24);
  color: #5b2a36;
}

body.theme-light .sheet-tabs,
body.theme-light .sheet-identity p,
body.theme-light .sheet-section p,
body.theme-light .sheet-stat,
body.theme-light .sheet-preferences span {
  color: #5b2a36;
  text-shadow: 0 1px 8px rgba(255, 111, 181, 0.14);
}

body.theme-light .sheet-tabs .active,
body.theme-light .sheet-identity h2,
body.theme-light .sheet-section h3,
body.theme-light .sheet-card h3,
body.theme-light .sheet-identity h2 *,
body.theme-light .sheet-section h3 *,
body.theme-light .sheet-card h3 * {
  color: #ff3f9a;
  text-shadow:
    0 0 10px rgba(255, 63, 154, 0.58),
    0 1px 4px rgba(91, 42, 54, 0.16);
}

body.theme-light .sheet-stat b,
body.theme-light .sheet-preferences b {
  color: #4d2630;
}

body.theme-light .sheet-heart,
body.theme-light .sheet-close,
body.theme-light .sheet-x,
body.theme-light .sheet-heart *,
body.theme-light .sheet-close *,
body.theme-light .sheet-x * {
  color: #ff3f9a;
  text-shadow: 0 0 12px rgba(255, 63, 154, 0.62);
}

body.theme-light .sheet-actions {
  background: linear-gradient(180deg, rgba(241, 222, 212, 0), rgba(241, 222, 212, 0.96) 34%);
}

body.theme-light .sheet-chat-btn {
  background: linear-gradient(135deg, #ff6fb5, #b94573);
  color: #5b2a36;
  text-shadow: 0 0 10px rgba(255, 248, 242, 0.62);
  box-shadow: 0 0 22px rgba(255, 63, 154, 0.36);
}

body.theme-light .sheet-chat-btn * {
  color: #5b2a36;
  text-shadow: 0 0 10px rgba(255, 248, 242, 0.62);
}

body.theme-light .toast {
  background: rgba(255, 248, 242, 0.96);
  color: #5b2a36;
}

/* Light theme form repair: readable brown input text, visible borders, no stretched fields. */
body.theme-light .create-character-view {
  padding: 0 16px 96px;
  color: #5b2a36;
}

body.theme-light .create-header {
  padding: 8px 0 4px;
}

body.theme-light .create-header h2 {
  color: #ff3f9a;
  text-shadow:
    0 0 12px rgba(255, 63, 154, 0.48),
    0 1px 4px rgba(91, 42, 54, 0.16);
}

body.theme-light .create-header p {
  color: #8a3156;
  text-shadow: 0 1px 8px rgba(255, 111, 181, 0.16);
}

body.theme-light .create-top-grid,
body.theme-light .admin-form-grid {
  max-width: 100%;
  overflow: visible;
}

body.theme-light .form-field,
body.theme-light .form-group,
body.theme-light .photo-uploader,
body.theme-light .behavior-panel {
  background:
    linear-gradient(135deg, rgba(255, 248, 242, 0.9), rgba(246, 222, 212, 0.82));
  border: 1px solid rgba(255, 63, 154, 0.24);
  border-radius: 16px;
  box-shadow:
    0 12px 24px rgba(154, 79, 103, 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.74);
  padding: 12px 14px;
  color: #5b2a36;
}

body.theme-light .form-field .input-wrapper,
body.theme-light .form-group .input-wrapper {
  min-height: 48px;
}

body.theme-light .field-content,
body.theme-light .form-field {
  min-width: 0;
}

body.theme-light .field-label,
body.theme-light .form-field > .field-label,
body.theme-light .setting-row span,
body.theme-light .npc-stat-row span {
  color: #9a4162;
  text-shadow: 0 0 8px rgba(255, 63, 154, 0.18);
}

body.theme-light .input-icon {
  color: #ff3f9a;
  text-shadow: 0 0 10px rgba(255, 63, 154, 0.48);
}

body.theme-light .form-input,
body.theme-light .form-textarea,
body.theme-light .settings-name-input,
body.theme-light .settings-motto textarea,
body.theme-light .npc-stat-input {
  width: 100%;
  min-width: 0;
  color: #5b2a36;
  -webkit-text-fill-color: #5b2a36;
  caret-color: #ff3f9a;
  background: rgba(255, 252, 248, 0.52);
  border: 1px solid rgba(255, 63, 154, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  text-shadow: 0 1px 7px rgba(255, 111, 181, 0.12);
}

body.theme-light .form-input::placeholder,
body.theme-light .form-textarea::placeholder,
body.theme-light .settings-name-input::placeholder,
body.theme-light .settings-motto textarea::placeholder {
  color: rgba(91, 42, 54, 0.58);
  -webkit-text-fill-color: rgba(91, 42, 54, 0.58);
}

body.theme-light .form-input:focus,
body.theme-light .form-textarea:focus,
body.theme-light .settings-name-input:focus,
body.theme-light .settings-motto textarea:focus,
body.theme-light .npc-stat-input:focus {
  border-color: rgba(255, 63, 154, 0.58);
  box-shadow:
    0 0 0 1px rgba(255, 63, 154, 0.18),
    0 0 18px rgba(255, 63, 154, 0.18);
  outline: none;
}

body.theme-light .settings-name-input,
body.theme-light .settings-name-input:focus {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  color: #251334;
  -webkit-text-fill-color: #251334;
}

.settings-name-input:-webkit-autofill,
.settings-name-input:-webkit-autofill:hover,
.settings-name-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-main);
  -webkit-box-shadow: 0 0 0 1000px #130a25 inset !important;
  box-shadow: 0 0 0 1000px #130a25 inset !important;
  transition: background-color 9999s ease-in-out 0s;
}

body.theme-light .settings-name-input:-webkit-autofill,
body.theme-light .settings-name-input:-webkit-autofill:hover,
body.theme-light .settings-name-input:-webkit-autofill:focus {
  -webkit-text-fill-color: #251334;
  -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
  box-shadow: 0 0 0 1000px transparent inset !important;
}

body.theme-light .form-textarea,
body.theme-light .settings-motto textarea {
  min-height: 96px;
  overflow: hidden;
  resize: none;
  white-space: pre-wrap;
  word-break: break-word;
}

body.theme-light .settings-motto textarea {
  min-height: 24px;
  max-height: 54px;
  padding: 7px 10px;
}

body.theme-light .photo-preview {
  border-color: rgba(255, 63, 154, 0.7);
  background-color: rgba(255, 252, 248, 0.44);
  color: #ff3f9a;
  text-shadow: 0 0 10px rgba(255, 63, 154, 0.42);
}

body.theme-light .photo-uploader p,
body.theme-light .context-text,
body.theme-light .range-labels,
body.theme-light #style-context-text {
  color: #9e4967;
}

body.theme-light .ratio-option {
  color: rgba(119, 67, 86, 0.88);
  border-color: rgba(255, 63, 154, 0.34);
  background: rgba(237, 207, 199, 0.78);
}

body.theme-light .ratio-option.active {
  color: #7b2f52;
  border-color: rgba(255, 63, 154, 0.82);
  background: rgba(255, 232, 239, 0.94);
  box-shadow: 0 0 18px rgba(255, 63, 154, 0.38);
  text-shadow: 0 0 7px rgba(255, 63, 154, 0.36);
}

/* Responsive catalog polish */
.catalog-grid,
.npc-grid,
.story-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  padding-inline: clamp(0px, 1vw, 6px);
}

.catalog-card,
.npc-card,
.story-card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.catalog-card-overlay strong,
.npc-card-overlay strong,
.story-card-overlay strong {
  font-size: clamp(12px, 3.8vw, 17px);
}

.catalog-card-overlay span,
.npc-card-overlay span,
.story-card-overlay small {
  font-size: clamp(6px, 1.9vw, 8px);
}

.npc-badge,
.story-badge {
  font-size: clamp(6px, 1.8vw, 8px);
  padding: clamp(3px, 1.2vw, 5px) clamp(5px, 1.8vw, 8px);
}

.catalog-favorite,
.npc-info,
.story-info {
  top: clamp(6px, 2vw, 10px);
  right: clamp(6px, 2vw, 10px);
}

.npc-add,
.story-card-action,
.catalog-edit,
.catalog-delete {
  width: clamp(30px, 8vw, 34px);
  height: clamp(30px, 8vw, 34px);
  right: clamp(10px, 2.4vw, 14px);
  bottom: clamp(14px, 3.2vw, 18px);
}

body.theme-light .personality-card {
  box-shadow:
    0 12px 24px rgba(110, 64, 49, 0.22),
    0 0 14px rgba(255, 63, 154, 0.12);
}

body.theme-light .personality-card::after {
  background:
    linear-gradient(180deg, rgba(84, 45, 35, 0.02), rgba(84, 45, 35, 0.58) 72%, rgba(84, 45, 35, 0.86)),
    radial-gradient(circle at 50% 100%, rgba(255, 63, 154, 0.2), transparent 48%);
}

body.theme-light .personality-card.active {
  box-shadow:
    0 0 0 1px rgba(255, 63, 154, 0.28),
    0 0 20px rgba(255, 63, 154, 0.42),
    0 14px 26px rgba(110, 64, 49, 0.24);
}

@media (max-width: 390px) {
  .catalog-view,
  .npc-view,
  .story-view {
    padding-inline: 8px;
  }

  .catalog-grid,
  .npc-grid,
  .story-grid {
    gap: 9px 6px;
    padding-inline: 0;
  }

  .catalog-card,
  .npc-card,
  .story-card {
    min-height: clamp(136px, 39vw, 168px);
    border-radius: 10px;
  }

  .catalog-card-overlay,
  .npc-card-overlay,
  .story-card-overlay {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }
}

.character-questionnaire-limit {
  margin: -4px 0 18px;
  color: rgba(224, 211, 242, 0.66);
  font-size: 11px;
  line-height: 1.35;
}

body.theme-light .character-questionnaire-limit {
  color: #95677d;
}

.participant-builder {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(178, 116, 255, 0.24);
  border-radius: 12px;
  background: rgba(12, 8, 27, 0.42);
}

.participant-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.participant-builder-head > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.participant-builder-head b {
  color: #f5edff;
  font-size: 13px;
}

.participant-builder-head span,
.participant-shared-hint {
  color: rgba(224, 211, 242, 0.66);
  font-size: 11px;
  line-height: 1.4;
}

.participant-add,
.participant-remove {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(190, 124, 255, 0.5);
  border-radius: 50%;
  background: rgba(126, 52, 255, 0.18);
  color: #d6a2ff;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.participant-add:disabled {
  opacity: 0.38;
  cursor: default;
}

.participant-list {
  display: grid;
  gap: 10px;
}

.participant-card {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(178, 116, 255, 0.18);
}

.participant-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.participant-card-head b {
  color: #dcbaff;
  font-size: 12px;
}

.participant-remove {
  width: 28px;
  height: 28px;
  font-size: 18px;
}

.participant-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.participant-fields .form-field:first-child,
.participant-fields .form-field:last-child {
  grid-column: 1 / -1;
}

.participant-shared-hint {
  margin: 10px 0 0;
}

.character-group-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: #d8a5ff;
  font-size: 10px;
  font-weight: 700;
}

body.theme-light .participant-builder {
  border-color: rgba(234, 121, 175, 0.32);
  background: rgba(255, 250, 252, 0.7);
}

body.theme-light .participant-builder-head b,
body.theme-light .participant-card-head b {
  color: #623247;
}

body.theme-light .participant-builder-head span,
body.theme-light .participant-shared-hint {
  color: #95677d;
}

body.theme-light .participant-add,
body.theme-light .participant-remove {
  border-color: rgba(233, 91, 158, 0.48);
  background: rgba(255, 216, 235, 0.72);
  color: #a9366d;
}

body.theme-light .participant-card {
  border-top-color: rgba(190, 90, 137, 0.2);
}

body.theme-light .character-group-badge {
  color: #a9366d;
}

@media (max-width: 520px) {
  .participant-fields {
    grid-template-columns: 1fr;
  }

  .participant-fields .form-field {
    grid-column: 1;
  }
}

.author-moderation-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: calc(100% - 20px);
  padding: 5px 8px;
  border: 1px solid rgba(190, 130, 255, 0.5);
  border-radius: 999px;
  background: rgba(20, 11, 39, 0.86);
  color: #f5eaff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.author-character-card > .author-moderation-badge {
  position: absolute;
  z-index: 5;
  top: 10px;
  left: 10px;
}

.author-moderation-badge.status-approved {
  border-color: rgba(75, 211, 150, 0.6);
  color: #aaf0ce;
}

.author-moderation-badge.status-changes_requested {
  border-color: rgba(255, 194, 86, 0.62);
  color: #ffe0a4;
}

.author-moderation-badge.status-rejected {
  border-color: rgba(255, 91, 145, 0.65);
  color: #ffb0cb;
}

body.theme-light .author-moderation-badge {
  background: rgba(255, 249, 252, 0.94);
  color: #833f65;
}

.admin-moderation-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.admin-moderation-summary button,
.admin-moderation-tabs button {
  border: 1px solid var(--admin-line);
  background: var(--admin-control);
  color: var(--admin-title);
  cursor: pointer;
}

.admin-moderation-summary button {
  min-height: 78px;
  padding: 12px;
  text-align: left;
}

.admin-moderation-summary span {
  display: block;
  color: var(--admin-dim);
  font-size: 11px;
}

.admin-moderation-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 25px;
}

.admin-moderation-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.admin-moderation-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
}

.admin-moderation-tabs button.is-active {
  border-color: var(--admin-action);
  background: var(--admin-control);
  color: var(--admin-action);
}

.admin-moderation-list {
  display: grid;
  gap: 14px;
}

.admin-moderation-card {
  padding: 16px;
  border: 1px solid var(--admin-line);
  border-radius: 8px;
  background: var(--admin-panel);
}

.admin-moderation-card-head {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.admin-moderation-card-head img,
.admin-moderation-card-head .admin-db-placeholder {
  width: 112px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
}

.admin-moderation-card-head h3 {
  margin: 10px 0 4px;
  color: var(--admin-title);
  font-size: 20px;
}

.admin-moderation-card-head p,
.admin-moderation-card-head small {
  display: block;
  margin: 0 0 5px;
  color: var(--admin-dim);
}

.admin-moderation-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--admin-line);
  border-radius: 6px;
  background: var(--admin-line);
}

.admin-moderation-fields div {
  padding: 10px 12px;
  background: var(--admin-panel-soft);
}

.admin-moderation-fields strong {
  color: var(--admin-dim);
  font-size: 10px;
  text-transform: uppercase;
}

.admin-moderation-fields p {
  margin: 5px 0 0;
  color: var(--admin-title);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.admin-moderation-card textarea {
  width: 100%;
  min-height: 72px;
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid var(--admin-line);
  border-radius: 6px;
  background: var(--admin-input);
  color: var(--admin-title);
  resize: vertical;
}

.admin-moderation-card textarea.admin-moderation-edit {
  min-height: 0;
  margin-top: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
}

.admin-moderation-field-count {
  margin-left: 6px;
  font-weight: 400;
  text-transform: none;
}

.admin-moderation-field-count.is-over,
.admin-moderation-card small.is-over {
  color: #e5484d;
  font-weight: 700;
}

.admin-moderation-existing-comment {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--admin-action);
  background: var(--admin-panel-soft);
  color: var(--admin-title);
}

.admin-moderation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.admin-moderation-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--admin-line);
  border-radius: 6px;
  background: var(--admin-control);
  color: var(--admin-title);
  cursor: pointer;
}

.admin-moderation-actions button:first-child {
  border-color: rgba(75, 211, 150, 0.52);
  color: #78dcb0;
}

@media (max-width: 760px) {
  .admin-moderation-summary,
  .admin-moderation-fields {
    grid-template-columns: 1fr;
  }

  .admin-moderation-card-head {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .admin-moderation-card-head img,
  .admin-moderation-card-head .admin-db-placeholder {
    width: 84px;
  }
}

/* Final admin theme separation: purple dark and pink light. */
body.admin-mode:not(.theme-light) {
  --admin-page: #090617;
  --admin-panel: #17102e;
  --admin-panel-soft: #20163c;
  --admin-control: #2a1d4a;
  --admin-input: #0f0a21;
  --admin-line: rgba(190, 132, 255, 0.27);
  --admin-title: #f8f1ff;
  --admin-copy: #d5c4ed;
  --admin-dim: #9f8bbd;
  --admin-action: #c084fc;
}

body.admin-mode:not(.theme-light),
body.admin-mode:not(.theme-light) .app-container {
  background: var(--admin-page) !important;
}

body.admin-mode:not(.theme-light) .admin-hero,
body.admin-mode:not(.theme-light) .admin-stat-card,
body.admin-mode:not(.theme-light) .admin-dashboard-section,
body.admin-mode:not(.theme-light) .admin-runtime-panel,
body.admin-mode:not(.theme-light) .admin-db-panel {
  background: linear-gradient(145deg, var(--admin-panel-soft), var(--admin-panel)) !important;
  border-color: var(--admin-line) !important;
  color: var(--admin-title) !important;
}

body.admin-mode:not(.theme-light) .admin-toggle-row,
body.admin-mode:not(.theme-light) .admin-field,
body.admin-mode:not(.theme-light) .admin-plan-card,
body.admin-mode:not(.theme-light) .admin-log-row,
body.admin-mode:not(.theme-light) .admin-user-card,
body.admin-mode:not(.theme-light) .admin-user-search,
body.admin-mode:not(.theme-light) .admin-db-card,
body.admin-mode:not(.theme-light) .admin-db-empty,
body.admin-mode:not(.theme-light) .admin-db-loading,
body.admin-mode:not(.theme-light) .admin-operation-grid article,
body.admin-mode:not(.theme-light) .admin-operation-grid button,
body.admin-mode:not(.theme-light) .admin-placeholder-state {
  background: var(--admin-control) !important;
  border-color: var(--admin-line) !important;
  color: var(--admin-title) !important;
  box-shadow: none !important;
}

body.admin-mode:not(.theme-light) .admin-field input,
body.admin-mode:not(.theme-light) .admin-field select,
body.admin-mode:not(.theme-light) .admin-field textarea,
body.admin-mode:not(.theme-light) .admin-plan-card input,
body.admin-mode:not(.theme-light) .admin-user-search input,
body.admin-mode:not(.theme-light) .admin-plan-select {
  background: var(--admin-input) !important;
  border-color: rgba(192, 132, 252, 0.36) !important;
  color: var(--admin-title) !important;
}

body.admin-mode:not(.theme-light) .admin-user-card strong,
body.admin-mode:not(.theme-light) .admin-db-info strong,
body.admin-mode:not(.theme-light) .admin-runtime-header h3,
body.admin-mode:not(.theme-light) .admin-section-heading h3,
body.admin-mode:not(.theme-light) .admin-toggle-row,
body.admin-mode:not(.theme-light) .admin-plan-card strong {
  color: var(--admin-title) !important;
}

body.admin-mode:not(.theme-light) .admin-user-card span,
body.admin-mode:not(.theme-light) .admin-user-meta small,
body.admin-mode:not(.theme-light) .admin-field,
body.admin-mode:not(.theme-light) .admin-plan-card label,
body.admin-mode:not(.theme-light) .admin-db-info span,
body.admin-mode:not(.theme-light) .admin-db-info small {
  color: var(--admin-copy) !important;
}

body.admin-mode.theme-light {
  --admin-page: #fff7fb;
  --admin-panel: #fffdfd;
  --admin-panel-soft: #fff4f8;
  --admin-control: #fff8fb;
  --admin-input: #ffffff;
  --admin-line: rgba(211, 73, 137, 0.24);
  --admin-title: #3d2034;
  --admin-copy: #735166;
  --admin-dim: #9b758b;
  --admin-action: #c93679;
  background:
    radial-gradient(circle at 75% 0%, rgba(255, 126, 183, 0.15), transparent 34%),
    linear-gradient(180deg, #fffafd, #fff4f8) !important;
}

body.admin-mode.theme-light .app-container {
  background: transparent !important;
}

body.admin-mode.theme-light .admin-sidebar {
  background: linear-gradient(180deg, #211538, #110b22 72%, #0d091a) !important;
  border-color: rgba(196, 132, 252, 0.24) !important;
}

body.admin-mode.theme-light .admin-sidebar-brand strong,
body.admin-mode.theme-light .admin-sidebar-nav button.is-active,
body.admin-mode.theme-light .admin-sidebar-nav button:hover,
body.admin-mode.theme-light .admin-sidebar-nav button:focus-visible {
  color: #fff !important;
}

body.admin-mode.theme-light .admin-sidebar-brand span,
body.admin-mode.theme-light .admin-sidebar-nav button,
body.admin-mode.theme-light .admin-sidebar-exit {
  color: rgba(242, 224, 255, 0.76) !important;
}

body.admin-mode.theme-light .admin-sidebar-nav button.is-active {
  border-color: rgba(221, 170, 255, 0.38) !important;
  background: linear-gradient(135deg, #6f35c8, #4e2aa5) !important;
}

body.admin-mode.theme-light .admin-hero,
body.admin-mode.theme-light .admin-stat-card,
body.admin-mode.theme-light .admin-dashboard-section,
body.admin-mode.theme-light .admin-runtime-panel,
body.admin-mode.theme-light .admin-db-panel {
  background: linear-gradient(145deg, var(--admin-panel), var(--admin-panel-soft)) !important;
  border-color: var(--admin-line) !important;
  color: var(--admin-title) !important;
  box-shadow: 0 10px 28px rgba(142, 69, 103, 0.07) !important;
}

body.admin-mode.theme-light .admin-hero h2,
body.admin-mode.theme-light .admin-hero span,
body.admin-mode.theme-light .admin-stat-card strong,
body.admin-mode.theme-light .admin-section-heading h3,
body.admin-mode.theme-light .admin-runtime-header h3,
body.admin-mode.theme-light .admin-toggle-row,
body.admin-mode.theme-light .admin-plan-card strong,
body.admin-mode.theme-light .admin-db-header h2,
body.admin-mode.theme-light .admin-db-info strong,
body.admin-mode.theme-light .admin-user-card strong,
body.admin-mode.theme-light .admin-placeholder-state strong,
body.admin-mode.theme-light .admin-operation-grid strong {
  color: var(--admin-title) !important;
  text-shadow: none !important;
}

body.admin-mode.theme-light .admin-kicker,
body.admin-mode.theme-light .admin-section-heading button,
body.admin-mode.theme-light .admin-runtime-header .admin-kicker {
  color: #dc3f84 !important;
}

body.admin-mode.theme-light .admin-hero span,
body.admin-mode.theme-light .admin-stat-card > span:not(.admin-stat-icon),
body.admin-mode.theme-light .admin-section-heading p,
body.admin-mode.theme-light .admin-placeholder-state p,
body.admin-mode.theme-light .admin-operation-grid span,
body.admin-mode.theme-light .admin-db-header span,
body.admin-mode.theme-light .admin-db-info span,
body.admin-mode.theme-light .admin-db-info small,
body.admin-mode.theme-light .admin-user-card span,
body.admin-mode.theme-light .admin-user-meta small,
body.admin-mode.theme-light .admin-user-search label,
body.admin-mode.theme-light .admin-field,
body.admin-mode.theme-light .admin-plan-card label,
body.admin-mode.theme-light .admin-log-row small {
  color: var(--admin-copy) !important;
}

body.admin-mode.theme-light .admin-stat-card .admin-stat-icon,
body.admin-mode.theme-light .admin-placeholder-state > span {
  background: #f2ddff !important;
  color: #9a4bd0 !important;
}

body.admin-mode.theme-light .admin-stat-card small {
  color: #2e9a62 !important;
}

body.admin-mode.theme-light .admin-control-card {
  border-color: rgba(201, 73, 137, 0.25) !important;
  background: linear-gradient(135deg, #fbe2ed, #eadcf9) !important;
  color: #743552 !important;
  box-shadow: none !important;
}

body.admin-mode.theme-light .admin-control-card:first-child {
  background: linear-gradient(135deg, #e84f95, #9f55d7) !important;
  color: #fff !important;
}

body.admin-mode.theme-light .admin-toggle-row,
body.admin-mode.theme-light .admin-field,
body.admin-mode.theme-light .admin-plan-card,
body.admin-mode.theme-light .admin-log-row,
body.admin-mode.theme-light .admin-user-card,
body.admin-mode.theme-light .admin-user-search,
body.admin-mode.theme-light .admin-db-card,
body.admin-mode.theme-light .admin-db-empty,
body.admin-mode.theme-light .admin-db-loading,
body.admin-mode.theme-light .admin-operation-grid article,
body.admin-mode.theme-light .admin-operation-grid button,
body.admin-mode.theme-light .admin-placeholder-state,
body.admin-mode.theme-light .admin-health-card,
body.admin-mode.theme-light .admin-health-backup,
body.admin-mode.theme-light .admin-health-count,
body.admin-mode.theme-light .admin-health-event {
  background: var(--admin-control) !important;
  border-color: var(--admin-line) !important;
  color: var(--admin-title) !important;
  box-shadow: none !important;
}

body.admin-mode.theme-light .admin-field input,
body.admin-mode.theme-light .admin-field select,
body.admin-mode.theme-light .admin-field textarea,
body.admin-mode.theme-light .admin-plan-card input,
body.admin-mode.theme-light .admin-user-search input,
body.admin-mode.theme-light .admin-plan-select {
  background: var(--admin-input) !important;
  border-color: rgba(201, 73, 137, 0.28) !important;
  color: var(--admin-title) !important;
  box-shadow: inset 0 1px 2px rgba(105, 44, 72, 0.04) !important;
}

body.admin-mode.theme-light .admin-field input::placeholder,
body.admin-mode.theme-light .admin-field textarea::placeholder,
body.admin-mode.theme-light .admin-user-search input::placeholder {
  color: #a88396 !important;
}

body.admin-mode.theme-light .admin-db-actions button,
body.admin-mode.theme-light .admin-user-controls button,
body.admin-mode.theme-light .admin-runtime-header button,
body.admin-mode.theme-light .admin-plan-card button,
body.admin-mode.theme-light .admin-top-actions button {
  background: #fbe8f1 !important;
  border-color: rgba(201, 73, 137, 0.3) !important;
  color: #8b365d !important;
}

body.admin-mode.theme-light .admin-db-actions .admin-db-danger,
body.admin-mode.theme-light .admin-user-controls .admin-db-danger {
  background: #fff0f3 !important;
  border-color: rgba(220, 55, 95, 0.34) !important;
  color: #bd3159 !important;
}

body.admin-mode.theme-light .admin-profile-chip {
  background: #fff9fc !important;
  border-color: rgba(201, 73, 137, 0.22) !important;
}

body.admin-mode.theme-light .admin-profile-chip strong {
  color: var(--admin-title) !important;
}

body.admin-mode.theme-light .admin-profile-chip small,
body.admin-mode.theme-light .admin-operation-grid .is-ok strong {
  color: #258a55 !important;
}

body.admin-mode.theme-light .admin-health-modal-panel {
  background: #fff9fc !important;
  border-color: rgba(201, 73, 137, 0.28) !important;
  box-shadow: 0 24px 70px rgba(112, 47, 77, 0.2) !important;
}

body.admin-mode.theme-light .admin-health-modal-backdrop {
  background: rgba(62, 25, 46, 0.34) !important;
}

.user-npc-form {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--card-bg);
}

.user-npc-form[hidden] {
  display: none;
}

.user-npc-form label {
  display: block;
  margin: 10px 0 6px;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 800;
}

.user-npc-form input,
.user-npc-form textarea,
.user-npc-form select,
.slot-detail-npc-add select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: rgba(12, 7, 29, 0.72);
  color: var(--text-main);
  padding: 10px 12px;
  font: inherit;
}

.user-npc-form textarea {
  resize: vertical;
  line-height: 1.4;
}

.user-npc-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.user-npc-form-actions,
.slot-detail-npc-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.user-npc-form-actions button,
.slot-detail-npc-add button {
  min-height: 42px;
  border: 1px solid var(--accent-purple);
  border-radius: 8px;
  background: rgba(82, 22, 140, 0.48);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.user-npc-form-actions button:last-child {
  border-color: var(--card-border);
  background: transparent;
  color: var(--text-muted);
}

.cabinet-npc-card {
  position: relative;
}

.cabinet-npc-card > img,
.cabinet-npc-card .npc-card-overlay {
  cursor: pointer;
}

.cabinet-npc-actions {
  position: absolute;
  z-index: 3;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}

.cabinet-npc-actions button,
.slot-npc-row button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(220, 180, 255, 0.58);
  border-radius: 50%;
  background: rgba(14, 8, 31, 0.86);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.cabinet-npc-delete,
.slot-npc-row button {
  border-color: rgba(244, 114, 182, 0.68) !important;
}

.slot-detail-npc-list {
  display: grid;
  gap: 8px;
}

.slot-npc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text-main);
}

.slot-npc-empty {
  color: var(--text-muted);
  font-size: 13px;
}

body.theme-light .user-npc-form input,
body.theme-light .user-npc-form textarea,
body.theme-light .user-npc-form select,
body.theme-light .slot-detail-npc-add select {
  background: rgba(255, 252, 247, 0.86);
  color: var(--text-main);
}

body.theme-light .cabinet-npc-actions button,
body.theme-light .slot-npc-row button {
  background: rgba(255, 248, 252, 0.92);
  color: #8e315a;
}

@media (max-width: 430px) {
  .user-npc-form-row,
  .user-npc-form-actions,
  .slot-detail-npc-add {
    grid-template-columns: 1fr;
  }
}

body.theme-light .setting-row,
body.theme-light .npc-stat-row {
  color: #5b2a36;
}

body.theme-light .setting-row b,
body.theme-light .npc-stat-row b,
body.theme-light .behavior-panel h3 {
  color: #ff3f9a;
  text-shadow: 0 0 10px rgba(255, 63, 154, 0.38);
}

body.theme-light .style-option,
body.theme-light .segment-btn {
  background: rgba(255, 248, 242, 0.74);
  border-color: rgba(255, 63, 154, 0.22);
  color: #5b2a36;
}

body.theme-light .style-option.active,
body.theme-light .segment-btn.active {
  background: linear-gradient(135deg, rgba(255, 111, 181, 0.24), rgba(255, 248, 242, 0.82));
  border-color: rgba(255, 63, 154, 0.72);
  color: #ff3f9a;
  box-shadow: 0 0 18px rgba(255, 63, 154, 0.28);
}

@media (max-width: 640px) {
  .create-character-view {
    padding-left: 14px;
    padding-right: 14px;
  }

  .admin-form-grid,
  .create-top-grid {
    grid-template-columns: 1fr;
  }

  .photo-uploader {
    max-width: 210px;
  }

  .setting-row,
  .npc-stat-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* Final UI cleanup: glow-only selected states and tidy avatar cards. */
.story-tools {
  display: none !important;
}

.personality-card,
body.theme-light .personality-card,
.personality-card.active,
body.theme-light .personality-card.active {
  background: transparent !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  transform: none !important;
}

.personality-card {
  min-width: clamp(86px, 22vw, 112px);
  width: clamp(86px, 22vw, 112px);
}

.avatar-wrapper {
  height: clamp(126px, 31vw, 156px);
  margin-bottom: 0;
}

.personality-card.active .avatar-wrapper {
  border-color: var(--accent-neon);
  box-shadow:
    0 0 0 1px rgba(192, 132, 252, 0.26),
    0 0 20px rgba(192, 132, 252, 0.58);
  transform: none;
}

.personality-name {
  bottom: 9px;
  padding: 3px 5px;
  border-radius: 8px;
  background: linear-gradient(180deg, transparent, rgba(5, 3, 15, 0.34));
  line-height: 1.15;
}

.avatar-levels {
  bottom: 33px;
}

.create-card .avatar-wrapper::after {
  background: linear-gradient(180deg, rgba(147, 51, 234, 0.06), rgba(5, 3, 15, 0.42));
}

body.theme-light .avatar-wrapper::after,
body.theme-light .create-card .avatar-wrapper::after {
  background:
    linear-gradient(180deg, rgba(103, 55, 42, 0.02), rgba(103, 55, 42, 0.44) 74%, rgba(103, 55, 42, 0.72)),
    radial-gradient(circle at 50% 100%, rgba(255, 63, 154, 0.2), transparent 54%);
}

body.theme-light .personality-card.active .avatar-wrapper {
  border-color: rgba(255, 63, 154, 0.88);
  box-shadow:
    0 0 0 1px rgba(255, 63, 154, 0.24),
    0 0 18px rgba(255, 63, 154, 0.48),
    0 14px 26px rgba(110, 64, 49, 0.22);
}

body.theme-light .personality-name {
  color: #ff4fa3;
  background: linear-gradient(180deg, transparent, rgba(103, 55, 42, 0.35));
  text-shadow:
    0 0 8px rgba(255, 79, 163, 0.62),
    0 1px 5px rgba(91, 42, 54, 0.42);
}

body.theme-light .create-text {
  background: transparent;
  color: #9e4967;
  text-shadow: 0 0 7px rgba(255, 79, 163, 0.2);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sheet-actions.single-action {
  grid-template-columns: 1fr;
}

/* Character form and avatar polish. */
.create-user-actions {
  align-items: stretch;
  margin: 14px 0 0;
}

.create-user-actions .primary-action,
.create-user-actions .secondary-action,
.admin-submit,
.primary-action,
.secondary-action {
  border-radius: 18px;
  min-height: 54px;
}

.secondary-action {
  box-shadow: 0 0 16px rgba(147, 51, 234, 0.16);
}

.create-character-view .admin-submit {
  margin-bottom: 0;
}

.personality-name {
  left: 7px;
  right: 7px;
  bottom: 7px;
  padding: 4px 6px;
  max-width: calc(100% - 14px);
  background: linear-gradient(180deg, transparent, rgba(5, 3, 15, 0.46));
}

.create-card .create-text {
  min-height: 18px;
  line-height: 1.2;
}

.sheet-preferences span {
  overflow-wrap: anywhere;
}

body.theme-light .primary-action,
body.theme-light .secondary-action,
body.theme-light .admin-submit,
body.theme-light .create-user-actions .primary-action,
body.theme-light .create-user-actions .secondary-action {
  border-color: rgba(255, 63, 154, 0.58);
  background: linear-gradient(135deg, rgba(255, 111, 181, 0.9), rgba(177, 75, 118, 0.82));
  color: #fff8fb;
  -webkit-text-fill-color: #fff8fb;
  text-shadow: var(--lux-neon-text);
  box-shadow: var(--lux-neon-box);
}

body.theme-light .secondary-action,
body.theme-light .create-user-actions .secondary-action {
  background: linear-gradient(135deg, rgba(255, 248, 242, 0.92), rgba(236, 202, 194, 0.86));
  color: #8a3156;
  -webkit-text-fill-color: #8a3156;
}

body.theme-light .personality-name {
  color: #ff4fa3;
  background: linear-gradient(180deg, transparent, rgba(103, 55, 42, 0.48));
}

body.theme-light .create-card .avatar-wrapper::after {
  background:
    linear-gradient(180deg, rgba(103, 55, 42, 0.04), rgba(103, 55, 42, 0.5) 74%, rgba(103, 55, 42, 0.78)),
    radial-gradient(circle at 50% 100%, rgba(255, 63, 154, 0.18), transparent 58%);
}

@media (max-width: 430px) {
  .create-user-actions {
    grid-template-columns: 1fr;
  }

  .create-user-actions .primary-action,
  .create-user-actions .secondary-action {
    min-height: 50px;
  }
}

.sheet-secondary-btn {
  border: 1px solid rgba(192, 132, 252, 0.46);
  background: rgba(8, 4, 18, 0.72);
}

.sheet-author-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.sheet-author-metrics[hidden] {
  display: none;
}

.sheet-author-metrics div {
  min-width: 0;
  min-height: 68px;
  display: grid;
  place-content: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid rgba(168, 85, 247, 0.34);
  border-radius: 8px;
  background: rgba(12, 7, 28, 0.72);
  text-align: center;
}

.sheet-author-metrics strong {
  color: #fff;
  font-size: 1.15rem;
  line-height: 1;
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.58);
}

.sheet-author-metrics span {
  color: rgba(243, 232, 255, 0.68);
  font-size: 0.72rem;
}

.sheet-danger-btn {
  border: 1px solid rgba(255, 77, 128, 0.5);
  background: rgba(78, 12, 38, 0.76);
  box-shadow: 0 0 18px rgba(255, 77, 128, 0.2);
}

.sheet-danger-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

body.theme-light .sheet-author-metrics div {
  border-color: rgba(255, 63, 154, 0.3);
  background: rgba(255, 248, 252, 0.78);
}

body.theme-light .sheet-author-metrics strong {
  color: #8d315d;
}

body.theme-light .sheet-author-metrics span {
  color: #745684;
}

body.theme-light .sheet-secondary-btn {
  border-color: rgba(255, 63, 154, 0.48);
  background: rgba(255, 248, 242, 0.78);
  color: #ff3f9a;
}

@media (max-width: 640px) {
  .admin-feature-grid {
    grid-template-columns: 1fr;
  }

  .story-achievement-row {
    grid-template-columns: auto 1fr;
  }

  .story-achievement-row select {
    grid-column: 1 / -1;
  }
}

/* Clean fixed catalog tiles: cover, name and short annotation only. */
.catalog-grid,
.npc-grid,
.story-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 14px);
  align-items: start;
  justify-items: stretch;
  padding-inline: clamp(10px, 3vw, 20px);
}

.catalog-card,
.npc-card,
.story-card {
  width: 100%;
  min-width: 0;
  max-width: none;
  aspect-ratio: 3 / 4;
  min-height: 0 !important;
  overflow: hidden;
}

.catalog-card.ratio-square,
.npc-card.ratio-square,
.story-card.ratio-square,
.catalog-card.ratio-portrait,
.npc-card.ratio-portrait,
.story-card.ratio-portrait,
.catalog-card.ratio-tall,
.npc-card.ratio-tall,
.story-card.ratio-tall {
  aspect-ratio: 3 / 4;
}

.catalog-card img,
.npc-card img,
.story-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalog-card::after,
.npc-card::after,
.story-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0 !important;
  height: 34%;
  pointer-events: none;
  background: linear-gradient(to top, rgba(4, 2, 12, 0.78), rgba(4, 2, 12, 0.24) 58%, transparent);
}

body.theme-light .catalog-card::after,
body.theme-light .npc-card::after,
body.theme-light .story-card::after {
  background: linear-gradient(to top, rgba(86, 47, 38, 0.58), rgba(86, 47, 38, 0.16) 58%, transparent);
}

.catalog-card-overlay,
.npc-card-overlay,
.story-card-overlay {
  left: 8px !important;
  right: 8px !important;
  bottom: 8px !important;
  z-index: 2;
  max-width: calc(100% - 16px);
  pointer-events: none;
}

.npc-card-overlay {
  right: 40px !important;
}

.catalog-card-overlay strong,
.npc-card-overlay strong,
.story-card-overlay strong {
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: #fff;
  line-height: 1.02;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.78), 0 0 9px rgba(255, 255, 255, 0.2);
}

.catalog-card-overlay span,
.npc-card-overlay span,
.story-card-overlay small {
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  max-height: 2.3em;
  line-height: 1.1;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.82);
}

.npc-badge,
.npc-info,
.story-badge,
.story-info,
.story-card-action,
.story-crown,
.story-unique {
  display: none !important;
}

.catalog-favorite,
.catalog-edit,
.catalog-delete,
.npc-add,
.npc-edit,
.story-edit {
  z-index: 6;
}

.admin-db-list.admin-db-catalog-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 3vw, 18px);
  align-items: start;
}

.admin-db-catalog-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  min-width: 0;
  padding: clamp(10px, 2.5vw, 14px);
  gap: 8px;
  overflow: hidden;
  isolation: isolate;
}

.admin-db-cover {
  grid-column: 1;
  width: min(100%, 124px);
  justify-self: center;
  min-height: 0;
  aspect-ratio: 3 / 4;
}

.admin-db-cover::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to top, rgba(4, 2, 12, 0.8), transparent);
}

.admin-db-cover-text {
  left: 8px !important;
  right: 8px !important;
  bottom: 8px !important;
  max-width: calc(100% - 16px);
}

.admin-db-cover-text strong,
.admin-db-cover-text small {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.admin-db-cover-text strong {
  -webkit-line-clamp: 2;
}

.admin-db-cover-text small {
  -webkit-line-clamp: 2;
  max-height: 2.3em;
}

.admin-db-meta {
  display: none !important;
}

.admin-db-catalog-card .admin-db-actions {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: end;
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  width: 38px;
  position: relative;
  z-index: 4;
}

.admin-db-catalog-card .admin-db-actions button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 18px;
  line-height: 1;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  font-family: inherit;
}

@media (max-width: 360px) {
  .catalog-grid,
  .npc-grid,
  .story-grid,
  .admin-db-list.admin-db-catalog-grid {
    gap: 7px;
    padding-inline: 8px;
  }

  .catalog-card-overlay,
  .story-card-overlay,
  .admin-db-cover-text {
    left: 6px !important;
    right: 6px !important;
    bottom: 6px !important;
  }

  .npc-card-overlay {
    left: 6px !important;
    right: 36px !important;
    bottom: 6px !important;
  }

  .admin-db-catalog-card {
    grid-template-columns: minmax(0, 1fr) 34px;
    padding: 8px;
    gap: 6px;
  }

  .admin-db-cover {
    width: min(100%, 112px);
  }

  .admin-db-catalog-card .admin-db-actions button {
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    border-radius: 10px;
    font-size: 16px;
  }
}

/* Hard stop for old story placeholders and dark detail surfaces in light mode. */
.story-info-block {
  grid-template-columns: 1fr !important;
}

.story-info-block img,
#story-detail-thumb {
  display: none !important;
}

body.theme-light .story-detail {
  background: linear-gradient(135deg, rgba(255, 249, 243, 0.98), rgba(250, 226, 216, 0.94)) !important;
  border-color: rgba(255, 92, 166, 0.32) !important;
  box-shadow: 0 24px 54px rgba(154, 79, 103, 0.16) !important;
}

body.theme-light .story-detail-hero {
  background: linear-gradient(135deg, rgba(255, 249, 243, 0.97), rgba(255, 233, 240, 0.9)) !important;
}

body.theme-light .story-detail-hero::after {
  background: linear-gradient(90deg, rgba(255, 249, 243, 0.9) 0%, rgba(255, 236, 242, 0.58) 42%, rgba(255, 236, 242, 0.04) 100%) !important;
}

body.theme-light .story-detail-copy h1,
body.theme-light .story-expects .section-title,
body.theme-light .story-info-block .section-title {
  color: #ff3f9a !important;
  text-shadow: 0 0 12px rgba(255, 63, 154, 0.28) !important;
}

body.theme-light .story-detail-copy p,
body.theme-light .story-info-block p,
body.theme-light .story-tip p,
body.theme-light .story-feature-grid p,
body.theme-light .story-meta-list small {
  color: #8a4b5b !important;
}

body.theme-light .story-meta-list b,
body.theme-light .story-feature-grid b,
body.theme-light .story-tip b {
  color: #6b3844 !important;
}

body.theme-light .story-meta-list span,
body.theme-light .story-feature-grid article,
body.theme-light .story-tip,
body.theme-light .story-info-block {
  background: rgba(255, 248, 242, 0.76) !important;
  border-color: rgba(255, 92, 166, 0.22) !important;
}

body.theme-light .story-detail-hero img {
  background: #fff0f6 !important;
  box-shadow: 0 18px 34px rgba(154, 79, 103, 0.16) !important;
}

body.theme-light .story-back-link {
  color: #ff3f9a !important;
}

/* Site visual refresh: shared MiTi backdrop and catalog header, scoped to existing views. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4, 5, 14, 0.24), rgba(4, 5, 14, 0.78)),
    url("assets/backgrounds/miti-city-bg.webp") top center / cover no-repeat;
}

body.theme-light::before {
  background:
    linear-gradient(180deg, rgba(255, 249, 253, 0.76), rgba(255, 239, 248, 0.88)),
    url("assets/backgrounds/miti-city-bg.webp") top center / cover no-repeat;
  filter: saturate(0.74) brightness(1.28);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle at 52% 0%, rgba(147, 51, 234, 0.24), transparent 34%),
    linear-gradient(90deg, rgba(2, 6, 23, 0.68), rgba(12, 4, 24, 0.16), rgba(2, 6, 23, 0.68));
}

body.theme-light::after {
  background:
    radial-gradient(circle at 52% 0%, rgba(255, 79, 163, 0.16), transparent 34%),
    linear-gradient(90deg, rgba(255, 247, 252, 0.82), rgba(255, 247, 252, 0.34), rgba(255, 247, 252, 0.82));
}

.home-view {
  padding-top: 20px !important;
}

.home-section:first-child {
  margin-top: 6px;
}

.catalog-view,
.npc-view,
.story-view {
  padding-top: 0;
}

.section-title,
.home-section-head .section-title {
  color: #f8f4ff !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  text-shadow:
    0 0 8px rgba(199, 153, 255, 0.24),
    0 2px 10px rgba(0, 0, 0, 0.38);
}

.home-view .home-section-head .section-title {
  max-width: min(70%, 360px);
  font-size: clamp(13px, 3.55vw, 16px) !important;
  line-height: 1.16 !important;
  text-wrap: balance;
}

.home-view .home-section-head {
  padding-left: 10px;
  border-left: 2px solid rgba(192, 132, 252, 0.62);
}

body.theme-light .home-view .home-section-head {
  border-left-color: rgba(255, 91, 168, 0.68);
}

.catalog-heading-row span,
.home-see-all {
  color: rgba(226, 218, 246, 0.74) !important;
  font-weight: 600 !important;
}

.catalog-card,
.npc-card,
.story-card,
.home-character-card,
.home-video-card,
.home-photo-card,
.home-placeholder-card {
  background: rgba(5, 10, 24, 0.58) !important;
  border-color: rgba(139, 92, 246, 0.42) !important;
  box-shadow:
    0 0 0 1px rgba(20, 184, 166, 0.03),
    0 0 22px rgba(88, 28, 135, 0.2),
    0 16px 38px rgba(0, 0, 0, 0.34) !important;
}

.catalog-card-overlay strong,
.npc-card-overlay strong,
.story-card-overlay strong,
.home-character-copy strong {
  color: #fff !important;
  font-weight: 800 !important;
  line-height: 1.02 !important;
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.64),
    0 0 12px rgba(192, 132, 252, 0.2) !important;
}

.catalog-card-overlay span,
.npc-card-overlay span,
.story-card-overlay small,
.home-character-copy span {
  color: rgba(238, 233, 248, 0.82) !important;
  font-weight: 500 !important;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.62);
}

body.theme-light .section-title,
body.theme-light .home-section-head .section-title {
  color: #392244 !important;
  text-shadow: 0 0 10px rgba(188, 104, 176, 0.12) !important;
}

body.theme-light .catalog-heading-row span,
body.theme-light .home-see-all {
  color: rgba(128, 63, 94, 0.86) !important;
}

/* Light theme: cabinet rose glow across site surfaces. */
body.theme-light {
  --card-border: rgba(255, 119, 181, 0.34);
  --accent-neon: #ff5ba8;
  --accent-purple: #ff5ba8;
  --text-muted: #9b6f87;
  --card-bg: rgba(255, 249, 253, 0.72);
  --input-bg: rgba(255, 255, 255, 0.72);
  color: #25152b;
}

body.theme-light::after {
  background:
    radial-gradient(circle at 52% 0%, rgba(255, 91, 168, 0.2), transparent 34%),
    linear-gradient(90deg, rgba(255, 247, 252, 0.78), rgba(255, 239, 248, 0.28), rgba(255, 247, 252, 0.78)) !important;
}

body.theme-light .logo,
body.theme-light .section-title,
body.theme-light .home-section-head .section-title,
body.theme-light .create-header h2,
body.theme-light .admin-hero h2 {
  color: #2a1530 !important;
  text-shadow:
    0 0 10px rgba(255, 91, 168, 0.16),
    0 1px 5px rgba(138, 49, 86, 0.08) !important;
}

body.theme-light .tagline,
body.theme-light .catalog-heading-row span,
body.theme-light .home-see-all,
body.theme-light .section-subtitle,
body.theme-light .create-header p {
  color: #a14f72 !important;
}

body.theme-light .btn-premium,
body.theme-light .btn-notification {
  color: #8c3159 !important;
  border-color: rgba(255, 91, 168, 0.72) !important;
  background: rgba(255, 249, 253, 0.52) !important;
  box-shadow:
    0 0 0 1px rgba(255, 91, 168, 0.12),
    0 0 16px rgba(255, 91, 168, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.86) !important;
  text-shadow:
    0 0 8px rgba(255, 91, 168, 0.34),
    0 1px 4px rgba(138, 49, 86, 0.08) !important;
}

body.theme-light .catalog-card,
body.theme-light .npc-card,
body.theme-light .story-card,
body.theme-light .home-character-card,
body.theme-light .home-video-card,
body.theme-light .home-user-list,
body.theme-light .empty-state-panel,
body.theme-light .section-container,
body.theme-light .gameplay-section,
body.theme-light .admin-stat-card,
body.theme-light .admin-control-card {
  background: rgba(255, 249, 253, 0.64) !important;
  border-color: rgba(255, 145, 196, 0.34) !important;
  box-shadow:
    0 12px 28px rgba(154, 79, 103, 0.12),
    0 0 16px rgba(255, 91, 168, 0.08) !important;
}

body.theme-light .catalog-card,
body.theme-light .npc-card,
body.theme-light .story-card {
  border-color: rgba(255, 119, 181, 0.42) !important;
  box-shadow:
    0 12px 24px rgba(95, 54, 82, 0.14),
    0 0 14px rgba(255, 91, 168, 0.12) !important;
}

body.theme-light .catalog-card-overlay strong,
body.theme-light .npc-card-overlay strong,
body.theme-light .story-card-overlay strong,
body.theme-light .home-character-copy strong {
  color: #fff !important;
  text-shadow:
    0 2px 10px rgba(64, 32, 50, 0.82),
    0 0 10px rgba(255, 91, 168, 0.22) !important;
}

body.theme-light .home-user-list,
body.theme-light .home-placeholder-card {
  background:
    linear-gradient(135deg, rgba(255, 250, 253, 0.86), rgba(251, 232, 243, 0.78)) !important;
  border-color: rgba(255, 119, 181, 0.38) !important;
  color: #4a2a56 !important;
  box-shadow:
    0 12px 28px rgba(154, 79, 103, 0.1),
    0 0 18px rgba(255, 91, 168, 0.08) !important;
}

body.theme-light .home-placeholder-card b,
body.theme-light .home-user-row strong {
  color: #7d3358 !important;
  text-shadow: 0 0 10px rgba(255, 91, 168, 0.16) !important;
}

body.theme-light .home-placeholder-card span,
body.theme-light .home-user-row span,
body.theme-light .home-page-note,
body.theme-light .home-section-note {
  color: rgba(99, 64, 118, 0.78) !important;
}

body.theme-light .home-page-note {
  border-left-color: rgba(202, 125, 232, 0.58);
}

body.theme-light .primary-action,
body.theme-light .secondary-action,
body.theme-light .admin-submit,
body.theme-light .btn-change-avatar,
body.theme-light .catalog-create-cta {
  border-color: rgba(255, 91, 168, 0.62) !important;
  background: linear-gradient(135deg, rgba(255, 116, 184, 0.95), rgba(205, 78, 136, 0.9)) !important;
  color: #fff8fb !important;
  -webkit-text-fill-color: #fff8fb !important;
  box-shadow:
    var(--lux-neon-box),
    0 10px 24px rgba(191, 72, 126, 0.2) !important;
  text-shadow: var(--lux-neon-text) !important;
}

[hidden],
body:not(.is-admin) [data-admin-only] {
  display: none !important;
}

body.is-admin [data-admin-only]:not([hidden]) {
  display: inline-flex;
}

.home-admin-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.home-character-row,
.home-video-row,
.home-photo-row {
  grid-template-columns: none !important;
  grid-auto-flow: column;
  grid-auto-columns: minmax(170px, 42vw);
  gap: clamp(12px, 3vw, 18px) !important;
  padding: 0 clamp(12px, 3vw, 24px) 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.home-character-row .home-character-card {
  display: block !important;
  width: 100%;
  aspect-ratio: 3 / 4;
  min-height: 0 !important;
  padding: 0 !important;
}

.home-character-card .home-rank {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 4;
  width: 30px;
  height: 30px;
  background: rgba(14, 9, 28, 0.62);
  backdrop-filter: blur(8px);
}

.home-character-card .home-card-stat {
  position: absolute;
  right: 10px;
  top: 42px;
  z-index: 4;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(10, 5, 22, 0.5);
  backdrop-filter: blur(8px);
}

.home-media-card {
  position: relative;
  display: block !important;
  width: 100%;
  scroll-snap-align: start;
  aspect-ratio: 3 / 4;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  text-decoration: none;
  border: 1px solid rgba(139, 92, 246, 0.42);
  border-radius: 8px;
  background: rgba(5, 10, 24, 0.58);
  box-shadow:
    0 0 0 1px rgba(20, 184, 166, 0.03),
    0 0 22px rgba(88, 28, 135, 0.2),
    0 16px 38px rgba(0, 0, 0, 0.34);
}

.home-media-card img,
.home-media-card video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: rgba(2, 6, 23, 0.82);
}

/* Until a frame arrives (app.js videoPreviewHtml): a small play mark instead of Chrome's grey icon. */
video.video-preview[poster] {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Ccircle cx='24' cy='24' r='23' fill='rgba(15,8,30,0.55)' stroke='rgba(233,213,255,0.55)' stroke-width='1.5'/%3E%3Cpath d='M19 15l15 9-15 9z' fill='rgba(243,232,255,0.9)'/%3E%3C/svg%3E") center 40% / 48px 48px no-repeat,
    radial-gradient(circle at 50% 35%, rgba(126, 34, 206, 0.35), rgba(2, 6, 23, 0.9) 70%);
}

.home-media-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0 !important;
  height: 34%;
  pointer-events: none;
  background: linear-gradient(to top, rgba(4, 2, 12, 0.78), rgba(4, 2, 12, 0.24) 58%, transparent);
}

.home-media-card .catalog-card-overlay {
  z-index: 3;
}

.home-media-card .catalog-card-overlay strong {
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: #fff !important;
  font-weight: 800 !important;
  line-height: 1.02 !important;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.78), 0 0 9px rgba(255, 255, 255, 0.2) !important;
}

.home-media-card .catalog-card-overlay span {
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  max-height: 2.3em;
  color: rgba(238, 233, 248, 0.82) !important;
  font-size: 10px;
  font-weight: 500 !important;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.82);
}

.home-media-badge {
  position: absolute !important;
  left: 9px;
  top: 9px;
  z-index: 4 !important;
  width: fit-content;
  max-width: calc(100% - 18px);
  padding: 4px 8px;
  border: 1px solid rgba(192, 132, 252, 0.42);
  border-radius: 999px;
  background: rgba(10, 5, 22, 0.52);
  color: #f8d7ff !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  line-height: 1;
  text-shadow: var(--lux-neon-text);
  backdrop-filter: blur(8px);
}

.home-media-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: rgba(248, 244, 255, 0.7);
  font-weight: 700;
  background:
    radial-gradient(circle at 50% 12%, rgba(192, 132, 252, 0.18), transparent 38%),
    rgba(5, 10, 24, 0.82);
}

.home-placeholder-card {
  grid-column: 1 / -1;
}

.image-fallback {
  object-fit: cover;
  opacity: 0.9;
}

.home-collection-view {
  min-height: calc(100vh - 160px);
  min-height: calc(100dvh - 160px);
}

img,
video,
iframe {
  max-width: 100%;
}

.home-collection-panel {
  margin-top: 4px !important;
}

.home-collection-head {
  align-items: center;
  justify-content: flex-start;
}

.home-collection-back {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid rgba(192, 132, 252, 0.5);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(12, 6, 24, 0.58);
  color: #efe6ff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    0 0 12px rgba(168, 85, 247, 0.24),
    inset 0 0 14px rgba(168, 85, 247, 0.12);
}

.home-collection-list {
  display: grid;
  gap: 14px;
}

.home-collection-characters,
.home-collection-videos,
.home-collection-photos {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-collection-author-characters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2.6vw, 16px) clamp(8px, 2.4vw, 14px);
  align-items: start;
}

.home-collection-users {
  grid-template-columns: 1fr;
}

.home-collection-list .home-character-card,
.home-collection-list .home-media-card {
  width: 100%;
}

.home-collection-list .home-character-card {
  display: block !important;
  aspect-ratio: 3 / 4;
  min-height: 0 !important;
  padding: 0 !important;
}

.home-media-card .catalog-edit,
.home-character-card .catalog-edit {
  right: 12px !important;
  bottom: 16px !important;
  width: 34px;
  height: 34px;
}

body.theme-light .home-collection-back {
  background: rgba(255, 249, 253, 0.78);
  border-color: rgba(255, 91, 168, 0.38);
  color: #8d3e62;
  box-shadow:
    0 8px 16px rgba(130, 57, 90, 0.12),
    0 0 16px rgba(255, 91, 168, 0.12);
}

@media (min-width: 560px) {
  .home-collection-characters,
  .home-collection-videos,
  .home-collection-photos {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

body.theme-light .home-media-card {
  background: rgba(255, 249, 253, 0.64);
  border-color: rgba(255, 119, 181, 0.42);
  box-shadow:
    0 12px 24px rgba(95, 54, 82, 0.14),
    0 0 14px rgba(255, 91, 168, 0.12);
}

body.theme-light .home-media-card::after {
  background: linear-gradient(to top, rgba(86, 47, 38, 0.58), rgba(86, 47, 38, 0.16) 58%, transparent);
}

@media (max-width: 390px) {
  .home-character-row,
  .home-video-row,
  .home-photo-row {
    grid-auto-columns: minmax(180px, 56vw);
    gap: 12px !important;
    padding-inline: 10px;
  }
}

@media (min-width: 640px) {
  .home-character-row,
  .home-video-row,
  .home-photo-row {
    grid-auto-columns: 210px;
  }
}

/* Custom category icons. */
.cat-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-block;
  color: currentColor;
  background-color: currentColor;
  -webkit-mask: var(--cat-icon) center / contain no-repeat;
  mask: var(--cat-icon) center / contain no-repeat;
  filter: var(--lux-neon-icon);
}

.catalog-tab.active .cat-icon {
  filter: var(--lux-neon-icon);
}

.cat-icon-grid {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='4' width='6' height='6' rx='1.4'/%3E%3Crect x='14' y='4' width='6' height='6' rx='1.4'/%3E%3Crect x='4' y='14' width='6' height='6' rx='1.4'/%3E%3Crect x='14' y='14' width='6' height='6' rx='1.4'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-crown {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 28 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19h20'/%3E%3Cpath d='M5.5 17 4 7l6 4.2L14 4l4 7.2L24 7l-1.5 10h-17Z'/%3E%3Cpath d='M8 21h12'/%3E%3Ccircle cx='4' cy='7' r='1.2' fill='black' stroke='none'/%3E%3Ccircle cx='14' cy='4' r='1.2' fill='black' stroke='none'/%3E%3Ccircle cx='24' cy='7' r='1.2' fill='black' stroke='none'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-heart {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 20s-7-4.5-9-9.1C1.6 7.7 3.4 5 6.5 5c1.8 0 3.2 1 3.9 2.2C11.1 6 12.5 5 14.3 5c3.1 0 5 2.7 3.6 5.9C16 15.5 12 20 12 20Z' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.cat-icon-moon {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M19.5 15.4A8.5 8.5 0 0 1 8.6 4.5 8.8 8.8 0 1 0 19.5 15.4Z' fill='black'/%3E%3C/svg%3E");
}

.cat-icon-star {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z'/%3E%3Cpath d='M19 16l.8 2.2L22 19l-2.2.8L19 22l-.8-2.2L16 19l2.2-.8L19 16Z'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-feather {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 4c-7.8.4-12.7 4-14.5 10.8-.5 1.9.9 3.7 2.8 3.7C15.2 18.5 19.1 12.5 20 4Z'/%3E%3Cpath d='M5 20c3.6-5.3 7.4-8.9 12-12'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-play {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M10 8.5l6 3.5-6 3.5v-7Z' fill='black' stroke='none'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-open-book {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5.5h6.2c1 0 1.8.8 1.8 1.8V20c0-1.3-1-2.3-2.3-2.3H4V5.5Z'/%3E%3Cpath d='M20 5.5h-6.2c-1 0-1.8.8-1.8 1.8V20c0-1.3 1-2.3 2.3-2.3H20V5.5Z'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-book {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 4h10.5A1.5 1.5 0 0 1 18 5.5V20H7.5A2.5 2.5 0 0 1 5 17.5v-12A1.5 1.5 0 0 1 6.5 4Z'/%3E%3Cpath d='M8 17h10'/%3E%3Cpath d='M9 8h6'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-users {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3'/%3E%3Cpath d='M3.5 20a5.5 5.5 0 0 1 11 0'/%3E%3Cpath d='M15.5 11a2.6 2.6 0 1 0 0-5.2'/%3E%3Cpath d='M16 15c2.5.4 4.3 2.2 4.5 5'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-user {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4.5 21a7.5 7.5 0 0 1 15 0'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-diamond {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l8 9-8 9-8-9 8-9Z'/%3E%3Cpath d='M8 12h8'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-cat {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 9V4l4 3h6l4-3v5c1.2 1.2 1.8 2.7 1.8 4.5 0 4-3.6 7.5-8.8 7.5S3.2 17.5 3.2 13.5C3.2 11.7 3.8 10.2 5 9Z'/%3E%3Cpath d='M9 13h.01M15 13h.01'/%3E%3Cpath d='M10 17c1.2.8 2.8.8 4 0'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-sprout {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21V10'/%3E%3Cpath d='M12 12c-4.2 0-7-2.5-7-7 4.7 0 7 2.8 7 7Z'/%3E%3Cpath d='M12 14c4.2 0 7-2.5 7-7-4.7 0-7 2.8-7 7Z'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-chip {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='7' y='7' width='10' height='10' rx='2'/%3E%3Cpath d='M9 3v4M15 3v4M9 17v4M15 17v4M3 9h4M3 15h4M17 9h4M17 15h4'/%3E%3Cpath d='M10 12h4'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-mask {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6c2.5-1.2 5.2-1.2 8 0 2.8-1.2 5.5-1.2 8 0v6c0 4.6-3.6 8-8 8s-8-3.4-8-8V6Z'/%3E%3Cpath d='M8 12h2M14 12h2M9 16c1.8 1 4.2 1 6 0'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-swords {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20l6-6M3 14l7 7M14 4l6 6M13 3l8 8'/%3E%3Cpath d='M20 20l-6-6M21 14l-7 7M10 4l-6 6M11 3l-8 8'/%3E%3C/g%3E%3C/svg%3E");
}

.cat-icon-bookmark {
  --cat-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 4h10a1 1 0 0 1 1 1v16l-6-3.5L6 21V5a1 1 0 0 1 1-1Z' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

body.theme-light .cat-icon {
  filter: var(--lux-neon-icon);
}

body.theme-light .catalog-tab.active .cat-icon {
  filter: var(--lux-neon-icon);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .title-icon {
  width: 24px;
  height: 22px;
  flex-basis: 24px;
  filter:
    drop-shadow(0 0 4px rgba(255, 245, 255, 0.86))
    drop-shadow(0 0 12px rgba(216, 180, 254, 0.78))
    drop-shadow(0 0 22px rgba(168, 85, 247, 0.42));
}

.home-view .section-title .title-icon {
  width: 22px;
  height: 20px;
  flex-basis: 22px;
}

body.theme-light .section-title .title-icon {
  filter:
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.8))
    drop-shadow(0 0 11px rgba(255, 91, 168, 0.54))
    drop-shadow(0 0 20px rgba(255, 145, 196, 0.28));
}

/* Header brand treatment: MiTi neon wordmark and premium glow. */
.logo,
body:not(.theme-light) .logo,
body:not(.theme-light).catalog-mode .logo,
body.theme-light .logo,
body.theme-light.catalog-mode .logo {
  margin: 0 !important;
  font-size: clamp(29px, 7vw, 38px) !important;
  font-weight: 300 !important;
  line-height: 0.92 !important;
  letter-spacing: 0.11em !important;
  font-family: "Montserrat", system-ui, sans-serif !important;
  background: linear-gradient(90deg, #f7d7ff 0%, #b76dff 38%, #e7ddff 58%, #72b8ff 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  -webkit-text-stroke: 0.7px rgba(245, 218, 255, 0.72);
  color: #f1d7ff !important;
  filter:
    drop-shadow(0 0 3px rgba(255, 235, 255, 0.86))
    drop-shadow(0 0 10px rgba(176, 91, 255, 0.82))
    drop-shadow(0 0 20px rgba(99, 179, 255, 0.38)) !important;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.78),
    0 0 12px rgba(190, 116, 255, 0.78),
    0 0 24px rgba(99, 179, 255, 0.42) !important;
}

.tagline,
body:not(.theme-light) .tagline,
body:not(.theme-light).catalog-mode .tagline,
body.theme-light .tagline,
body.theme-light.catalog-mode .tagline {
  margin-top: 8px !important;
  color: rgba(255, 250, 255, 0.9) !important;
  font-size: clamp(9px, 2.25vw, 12px) !important;
  font-weight: 500 !important;
  letter-spacing: 0.15em !important;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.72),
    0 0 10px rgba(198, 168, 255, 0.36) !important;
}

body.theme-light .tagline,
body.theme-light.catalog-mode .tagline {
  color: rgba(113, 63, 88, 0.92) !important;
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.62),
    0 0 7px rgba(255, 91, 168, 0.16) !important;
}

.btn-premium,
.btn-premium[data-subscription="general"],
.btn-premium[data-subscription="basic"],
.btn-premium[data-subscription="premium"],
body.theme-light .btn-premium,
body.theme-light .btn-premium[data-subscription="general"],
body.theme-light .btn-premium[data-subscription="basic"],
body.theme-light .btn-premium[data-subscription="premium"] {
  position: relative !important;
  min-height: 38px !important;
  padding: 0 16px !important;
  border: 1px solid rgba(181, 91, 255, 0.55) !important;
  border-radius: 999px !important;
  background:
    radial-gradient(circle at 20% 50%, rgba(171, 64, 255, 0.86), rgba(100, 34, 173, 0.46) 38%, rgba(15, 8, 31, 0.82) 70%),
    linear-gradient(90deg, rgba(111, 33, 205, 0.94), rgba(21, 12, 43, 0.86) 58%, rgba(17, 10, 33, 0.78)) !important;
  color: #fff8ff !important;
  -webkit-text-fill-color: #fff8ff !important;
  box-shadow:
    var(--lux-neon-box) !important;
  text-shadow: var(--lux-neon-text) !important;
}

.btn-premium svg {
  width: 14px !important;
  height: 14px !important;
  color: #fff2ff !important;
  filter: var(--lux-neon-icon) !important;
}

.btn-premium span {
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em !important;
}

body.theme-light .btn-premium,
body.theme-light .btn-premium[data-subscription="general"],
body.theme-light .btn-premium[data-subscription="basic"],
body.theme-light .btn-premium[data-subscription="premium"] {
  border-color: rgba(255, 91, 168, 0.54) !important;
  background:
    radial-gradient(circle at 20% 50%, rgba(255, 91, 168, 0.5), rgba(255, 145, 196, 0.3) 38%, rgba(255, 249, 253, 0.92) 70%),
    linear-gradient(90deg, rgba(255, 111, 181, 0.74), rgba(255, 249, 253, 0.92) 58%, rgba(255, 247, 252, 0.86)) !important;
  color: #8c3159 !important;
  -webkit-text-fill-color: #8c3159 !important;
  box-shadow: var(--lux-neon-box) !important;
  text-shadow: var(--lux-neon-text) !important;
}

body.theme-light .logo,
body.theme-light.catalog-mode .logo {
  background: linear-gradient(90deg, #ff7fbd 0%, #ff4fa3 42%, #d75f94 68%, #a56ccb 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  -webkit-text-stroke: 0.45px rgba(255, 140, 196, 0.42);
  filter:
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.68))
    drop-shadow(0 0 8px rgba(255, 91, 168, 0.46))
    drop-shadow(0 0 14px rgba(255, 145, 196, 0.22)) !important;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.58),
    0 0 10px rgba(255, 91, 168, 0.34) !important;
}

@media (max-width: 390px) {
  .header {
    min-height: 80px !important;
    padding: 14px 18px 12px !important;
  }

  .logo,
  body:not(.theme-light) .logo,
  body.theme-light .logo {
    font-size: 28px !important;
    letter-spacing: 0.1em !important;
  }

  .tagline,
  body:not(.theme-light) .tagline,
  body.theme-light .tagline {
    font-size: 10px !important;
    letter-spacing: 0.14em !important;
  }

  .btn-premium,
  body.theme-light .btn-premium {
    min-height: 36px !important;
    padding-inline: 14px !important;
  }
}

/* Cabinet: personal character cards and slot refresh */
.user-character-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 8px;
}

.user-character-actions button,
.slot-detail-refresh {
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid rgba(216, 180, 254, 0.55);
  border-radius: 10px;
  background: rgba(82, 22, 140, 0.42);
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.slot-detail-refresh {
  width: 100%;
  margin: 6px 0;
}

#slot-detail-refresh-block small {
  text-align: left;
}

body.theme-light .user-character-actions button,
body.theme-light .slot-detail-refresh {
  background: rgba(255, 249, 253, 0.82);
  border-color: rgba(255, 91, 168, 0.48);
  color: #8c3159;
}

.saved-create-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#user-characters-count {
  color: var(--text-muted);
  font-size: 15px;
  white-space: nowrap;
}

/* Вкладки каталога: «ПЕРСОНАЖИ» с иконкой в строку не помещались в кнопку,
   иконка вылезала за край. Иконка над подписью — всё влезает на любой ширине. */
.catalog-mode-switch .sub-nav-item {
  flex-direction: column;
  gap: 3px;
  padding: 7px 4px;
  font-size: 10px;
  text-align: center;
  line-height: 1.15;
}

@media (max-width: 430px) {
  .catalog-mode-switch {
    gap: 6px;
    padding: 10px 10px;
  }

  .catalog-mode-switch .sub-nav-item {
    font-size: 9.5px;
  }

  /* Title on its own line, the create button full width below it. */
  .saved-header-row {
    flex-wrap: wrap;
  }

  .saved-header-row .saved-create-btn {
    width: 100%;
  }

  nav.sub-nav {
    gap: 6px;
    padding: 10px 10px;
  }

  nav.sub-nav .sub-nav-item {
    flex-direction: column;
    gap: 3px;
    font-size: 9.5px;
    text-align: center;
    line-height: 1.15;
  }
}