/* ═══════════════════════════════════════════════════════
   NIXA CSS v2 — Premium Dark Design System
   ═══════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root, [data-theme="dark"] {
  color-scheme: dark;
  /* Backgrounds */
  --bg:        #0c0d16;
  --bg2:       rgba(0, 0, 0, 0.3);
  --surface:   rgba(255, 255, 255, 0.05);
  --surface2:  rgba(255, 255, 255, 0.08);
  --surface3:  rgba(255, 255, 255, 0.12);

  /* Borders */
  --border:    rgba(255, 255, 255, 0.1);
  --border2:   rgba(255, 255, 255, 0.2);

  /* Text */
  --text:      #ffffff;
  --text2:     rgba(255, 255, 255, 0.7);
  --muted:     rgba(255, 255, 255, 0.4);

  /* Accents */
  --accent:    #4f46e5;
  --accent-h:  #6366f1;
  --accent-lo: rgba(79, 70, 229, 0.2);
  --accent2:   #a855f7;
  --accent2-lo:rgba(168, 85, 247, 0.12);
  --green:     #34d399;
  --yellow:    #fbbf24;
  --red:       #f87171;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow:    0 4px 16px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.6);
  --glow:      0 0 20px rgba(79, 70, 229,.2);

  /* Liquid Glass */
  --glass-bg:      rgba(255, 255, 255, 0.06);
  --glass-border:  rgba(255, 255, 255, 0.14);
  --glass-shine:   rgba(255, 255, 255, 0.10);
  --glass-shadow:  0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.10);
  --glass-blur:    blur(24px) saturate(160%);

  /* Radii */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* Transitions */
  --t: .18s ease;
  --t-slow: .3s ease;

  /* Layout */
  --navbar-h: 72px;
  --sidebar-w: 260px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg:        #f8fafc;
  --bg2:       rgba(255, 255, 255, 0.8);
  --surface:   #ffffff;
  --surface2:  rgba(0, 0, 0, 0.04);
  --surface3:  rgba(0, 0, 0, 0.08);

  --border:    rgba(0, 0, 0, 0.08);
  --border2:   rgba(0, 0, 0, 0.15);

  --text:      #0f172a;
  --text2:     #334155;
  --muted:     #64748b;

  --accent:    #4f46e5;
  --accent-h:  #4338ca;
  --accent-lo: rgba(79, 70, 229, 0.1);
  --accent2:   #9333ea;
  --accent2-lo:rgba(147, 51, 234, 0.1);
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --glow:      0 0 20px rgba(79, 70, 229,.15);

  /* Liquid Glass (light) */
  --glass-bg:      rgba(255, 255, 255, 0.55);
  --glass-border:  rgba(255, 255, 255, 0.80);
  --glass-shine:   rgba(255, 255, 255, 0.75);
  --glass-shadow:  0 8px 24px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255,255,255,0.90);
  --glass-blur:    blur(20px) saturate(180%);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
  visibility: visible;
}
body.nixa-ready {
  visibility: visible;
  animation: nixaFadeIn 0.18s ease;
}
@keyframes nixaFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

html::before {
  content: '';
  position: fixed;
  top: -10%; left: -10%; width: 50%; height: 50%;
  background: rgba(49, 46, 129, 0.4);
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
}

body::before {
  content: '';
  position: fixed;
  bottom: -10%; right: -10%; width: 60%; height: 60%;
  background: rgba(88, 28, 135, 0.3);
  border-radius: 50%;
  filter: blur(150px);
  z-index: -1;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  top: 20%; right: 10%; width: 30%; height: 30%;
  background: rgba(30, 58, 138, 0.2);
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  pointer-events: none;
}

.char-card,
.navbar,
.chat-sidebar,
.chat-input-wrap,
.creator-form-section,
.preview-card,
.login-card,
.profile-greeting,
.user-list-item,
.chat-input-box,
.msg-bubble,
.debug-panel,
.modal,
.toast,
.history-item,
.form-input,
.form-textarea,
.form-select,
.avatar-upload-area {
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent-lo); color: var(--text); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Navbar ────────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--navbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg2) 65%, transparent);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 4px 24px rgba(0,0,0,0.18);
}

.navbar-logo {
  font-size: 26px; font-weight: 850; letter-spacing: -.7px;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.nixa-logo-svg {
  width: 58px !important;
  height: 58px !important;
  border-radius: 12px;
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.45));
  transition: transform var(--t) cubic-bezier(0.16, 1, 0.3, 1), filter var(--t) cubic-bezier(0.16, 1, 0.3, 1);
  display: block;
}
.navbar-logo:hover .nixa-logo-svg {
  transform: scale(1.08) rotate(-2deg);
  filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.85));
}
.navbar-logo img {
  width: 58px !important; 
  height: 58px !important; 
  border-radius: 12px; 
  filter: drop-shadow(0 0 8px rgba(100, 100, 255, 0.4));
  transition: transform var(--t) cubic-bezier(0.16, 1, 0.3, 1), filter var(--t) cubic-bezier(0.16, 1, 0.3, 1);
}
.navbar-logo:hover img {
  transform: scale(1.06);
  filter: drop-shadow(0 0 12px rgba(100, 100, 255, 0.7));
}
.navbar-logo span { color: inherit; }

.navbar-spacer { flex: 1; }

.navbar-links {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
}
.navbar-links::-webkit-scrollbar { display: none; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 18px; border-radius: 12px;
  border: 1px solid transparent; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  transition: all var(--t) cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap; line-height: 1;
  background: var(--surface2); color: var(--text2);
  position: relative; overflow: hidden;
}
/* Subtle glass highlight on top edge */
.btn::before {
  content: '';
  position: absolute; top: 0; left: 10%; right: 10%;
  height: 1px;
  background: rgba(255,255,255,0.18);
  pointer-events: none;
  border-radius: 99px;
}
.btn:hover {
  background: var(--surface3); color: var(--text);
  transform: translateY(-1.5px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255,255,255,0.10);
  border-color: var(--glass-border);
}
.btn:active {
  transform: translateY(0.5px) scale(.97);
  box-shadow: none;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-sm { padding: 7px 13px; font-size: 12.5px; border-radius: 9px; }
.btn-sm svg { width: 13px; height: 13px; }

/* Icon-only buttons — square, balanced */
.btn-icon { padding: 8px; min-width: 34px; min-height: 34px; }
.btn-sm.btn-icon { padding: 7px; min-width: 30px; min-height: 30px; }

.btn-primary {
  background: var(--accent); color: #fff;
  border-color: rgba(139,92,246,0.4);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3), inset 0 1px 0 rgba(255,255,255,0.20);
}
.btn-primary::before { background: rgba(255,255,255,0.22); }
.btn-primary:hover {
  background: var(--accent-h); color: #fff;
  box-shadow: 0 6px 22px rgba(139, 92, 246, 0.50), inset 0 1px 0 rgba(255,255,255,0.22);
}

.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid transparent;
}
.btn-ghost::before { display: none; }
.btn-ghost:hover {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text);
  border-color: var(--glass-border);
  box-shadow: var(--glass-shadow);
  transform: translateY(-1px);
}

.btn-danger { background: var(--red); color: #fff; border-color: rgba(248,113,113,0.4); }
.btn-danger:hover { background: #ef4444; box-shadow: 0 4px 14px rgba(248,113,113,0.35); }

.active-view { background: var(--accent-lo) !important; color: var(--accent) !important; }

/* ── Search Bar ────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 6px 10px;
  transition: border-color var(--t);
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.search-bar input {
  border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 13px; color: var(--text);
  width: 100%;
}
.search-bar input::placeholder { color: var(--muted); }

/* ── Lang Switcher ─────────────────────────────────────── */
.lang-switcher {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 2px;
}
.lang-btn {
  padding: 4px 8px; border-radius: 6px; border: none;
  font-size: 11px; font-weight: 600; cursor: pointer;
  font-family: inherit; background: transparent; color: var(--muted);
  transition: all var(--t);
}
.lang-btn.active { background: var(--accent); color: #fff; }
.lang-btn:hover:not(.active) { color: var(--text); }

/* ── Page Layout ───────────────────────────────────────── */
.page {
  padding-top: calc(var(--navbar-h) + 40px);
  padding-bottom: 60px;
  animation: pageFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageFadeIn {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ── Hero ──────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 20px 0 44px;
}

.hero-badge {
  display: inline-flex; align-items: center;
  padding: 5px 14px; margin-bottom: 20px;
  border-radius: 99px;
  background: var(--accent-lo); color: var(--accent);
  font-size: 11.5px; font-weight: 600; letter-spacing: .5px;
  border: 1px solid var(--accent)30;
}

.hero-title {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 700; line-height: 1.15;
  letter-spacing: -.5px;
  margin-bottom: 14px;
  background: linear-gradient(to right, #818cf8 0%, #c084fc 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 15px; color: var(--text2); max-width: 500px; margin: 0 auto;
}

/* ── Filter Tabs ───────────────────────────────────────── */
.filter-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 24px;
}

.filter-tab {
  padding: 6px 14px; border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text2);
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: all var(--t);
}
.filter-tab:hover { border-color: var(--border2); color: var(--text); }
.filter-tab.active {
  background: var(--accent); color: #fff;
  border-color: transparent;
}

/* ── Section Header ────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.section-title { font-size: 15px; font-weight: 600; color: var(--text); }
.section-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Character Grid ────────────────────────────────────── */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.char-list {
  display: flex; flex-direction: column; gap: 8px;
}

/* ── Character Card ────────────────────────────────────── */
.char-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
}

.char-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--char-color, var(--accent));
  opacity: 0;
  transition: opacity var(--t);
}

.char-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.char-card:hover::before { opacity: 1; }

.char-card-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}

.char-avatar {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
  overflow: hidden;
}
.char-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.char-name {
  font-size: 14.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.char-desc {
  font-size: 12.5px; color: var(--text2);
  line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
  min-height: 36px;
}

.char-tags {
  display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
}

.char-tag {
  padding: 3px 8px; border-radius: 99px;
  font-size: 10.5px; font-weight: 500;
  background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border);
}

.char-edit-btn {
  position: absolute; top: 14px; right: 14px;
  opacity: 0; transition: opacity var(--t);
}
.char-card:hover .char-edit-btn { opacity: 1; }

/* List view variant */
.char-list .char-card {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 14px;
}
.char-list .char-card-header { margin-bottom: 0; flex: 1; }
.char-list .char-avatar { width: 38px; height: 38px; border-radius: 10px; font-size: 18px; }
.char-list .char-desc {
  display: none;
}
.char-list .char-tags { flex-wrap: nowrap; }
.char-list .char-card-footer { margin-left: auto; }

/* Discover toolbar */
.discover-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.sort-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.sort-tab {
  padding: 6px 14px; border-radius: 99px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text2);
  cursor: pointer; transition: all var(--t);
}
.sort-tab:hover { border-color: var(--border2); color: var(--text); }
.sort-tab.active {
  background: var(--accent)18; border-color: var(--accent); color: var(--accent);
}
.period-select {
  padding: 6px 30px 6px 12px; border-radius: var(--r); font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  cursor: pointer; appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><polyline points="6 9 12 15 18 9"></polyline></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.char-meta-line {
  font-size: 11px; color: var(--muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.char-badge-trending {
  position: absolute; top: 12px; right: 12px; font-size: 14px;
  filter: drop-shadow(0 0 6px rgba(251, 146, 60, 0.5));
}
.char-card-footer {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
  padding-top: 10px; border-top: 1px solid var(--border);
}
.char-like-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); font-size: 12px;
  cursor: pointer; transition: all var(--t);
}
.char-like-btn:hover { border-color: #f472b6; color: #f472b6; }
.char-like-btn.liked { border-color: #f472b6; color: #f472b6; background: #f472b612; }
.char-like-icon { font-size: 14px; line-height: 1; }
.char-stat { font-size: 12px; color: var(--muted); margin-left: auto; }
.char-chat-btn { flex-shrink: 0; }

/* ── Empty State ───────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px; text-align: center;
}
.empty-icon { font-size: 40px; margin-bottom: 14px; opacity: .6; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--muted); }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--glass-bg);
  color: var(--text);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  padding: 10px 22px; border-radius: 99px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--glass-shadow);
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  opacity: 0; z-index: 9999; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t);
  backdrop-filter: blur(4px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r-xl); padding: 28px;
  min-width: 320px; max-width: 400px; width: 90%;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-sub { font-size: 13px; color: var(--text2); margin-bottom: 20px; line-height: 1.5; }

/* ══════════════════════════════════════════════════════════
   CHAT PAGE
   ══════════════════════════════════════════════════════════ */

.chat-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--navbar-h);
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
.chat-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--bg2) 70%, transparent);
  border-right: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.04);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
/* Top-edge glass shine */
.chat-sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  pointer-events: none; z-index: 1;
}

.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
}

.chat-char-info {
  display: flex; align-items: center; gap: 10px;
}

.chat-char-avatar {
  width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0; overflow: hidden;
}
.chat-char-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.chat-char-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  line-height: 1.2;
}
.chat-char-model { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Sidebar "about" section ───────────────────────────── */
.sidebar-char-desc {
  padding: 10px 16px;
  font-size: 11.5px; color: var(--text2); line-height: 1.5;
  border-bottom: 1px solid var(--border);
}
.sidebar-char-tags {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-char-stats {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px 10px; font-size: 11.5px; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.sidebar-profile-link {
  margin-left: auto; color: var(--accent); text-decoration: none; font-weight: 500;
}
.sidebar-profile-link:hover { text-decoration: underline; }

.chat-history-list {
  flex: 1; overflow-y: auto;
  padding: 8px 8px;
  display: flex; flex-direction: column; gap: 3px;
}

.history-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm);
  cursor: pointer; transition: background var(--t);
  position: relative;
}
.history-item:hover { background: var(--surface2); }
.history-item.active { background: var(--accent-lo); }
.history-item.active .history-title { color: var(--accent); }

.history-title {
  flex: 1; font-size: 12.5px; color: var(--text2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-date { font-size: 10px; color: var(--muted); }

.history-del {
  position: absolute; right: 6px;
  opacity: 0; transition: opacity var(--t);
  padding: 3px; border-radius: 4px; cursor: pointer;
  color: var(--muted); background: none; border: none;
}
.history-item:hover .history-del { opacity: 1; }
.history-del:hover { color: var(--red); background: var(--surface3); }
.history-del svg { width: 12px; height: 12px; }

/* ── Main Chat Area ────────────────────────────────────── */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

.status-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 18px;
  background: color-mix(in srgb, var(--bg2) 60%, transparent);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 1px 0 rgba(255,255,255,0.05);
  font-size: 11.5px; color: var(--muted);
  flex-shrink: 0;
}

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
  transition: background .3s;
}
.status-dot.thinking {
  background: var(--yellow);
  animation: pulse-dot 1s infinite;
}
.status-dot.error { background: var(--red); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.chat-messages {
  flex: 1; overflow-y: auto; padding: 24px 0;
}
.chat-messages-inner {
  max-width: 740px; margin: 0 auto; padding: 0 20px;
  display: flex; flex-direction: column; gap: 2px;
}

/* ── Messages ──────────────────────────────────────────── */
.msg-row {
  display: flex; gap: 12px;
  padding: 6px 0;
  animation: fadeInUp .4s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}
.msg-row.user { flex-direction: row-reverse; }

@keyframes fadeInUp {
  0% { opacity: 0; transform: translateY(12px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-avatar {
  width: 30px; height: 30px; border-radius: 9px;
  flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  margin-top: 4px;
}
.msg-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

.msg-bubble-wrap { display: flex; flex-direction: column; gap: 4px; max-width: 85%; }
.msg-row.user .msg-bubble-wrap { align-items: flex-end; }

.msg-bubble {
  padding: 12px 18px; border-radius: 20px;
  font-size: 15px; line-height: 1.6;
  color: var(--text);
  box-shadow: 0 8px 28px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: background .28s cubic-bezier(0.16, 1, 0.3, 1),
              border-color .28s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow .28s cubic-bezier(0.16, 1, 0.3, 1),
              transform .28s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

/* Liquid glass — assistant bubble */
.msg-row.assistant .msg-bubble {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 6px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18),
              inset 0 1px 0 var(--glass-shine),
              inset 0 -1px 0 rgba(0,0,0,0.06);
}
/* Top-edge highlight on assistant bubble */
.msg-row.assistant .msg-bubble::before {
  content: '';
  position: absolute; top: 0; left: 12px; right: 12px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
  border-radius: 99px; pointer-events: none;
}

/* User bubble — premium gradient + glass depth */
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg,
    var(--accent) 0%,
    color-mix(in srgb, var(--accent) 72%, #12c2e9) 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 6px 24px rgba(79,70,229,0.30),
              inset 0 1px 0 rgba(255,255,255,0.25),
              inset 0 -1px 0 rgba(0,0,0,0.10);
}

.msg-meta {
  display: flex; align-items: center; gap: 8px;
  padding: 0 2px;
}
.msg-time { font-size: 10px; color: var(--muted); }

.msg-actions {
  display: flex; gap: 3px; opacity: 0;
  transition: opacity var(--t);
}
.msg-row:hover .msg-actions { opacity: 1; }

.msg-action-btn {
  background: none; border: none; cursor: pointer;
  padding: 3px 5px; border-radius: 5px;
  color: var(--muted); font-size: 10px;
  display: flex; align-items: center; gap: 3px;
  transition: all var(--t);
}
.msg-action-btn svg { width: 11px; height: 11px; }
.msg-action-btn:hover { background: var(--surface2); color: var(--text); }
.msg-action-btn.danger:hover { color: var(--red); }

.typing-dots { display: flex; gap: 5px; padding: 16px 20px; align-items: center; }
.liquid-typing {
  min-width: 70px;
  justify-content: center;
  animation: liquidBreath 1.8s ease-in-out infinite;
}
.typing-dot { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: typeBounce 1.4s infinite both; }
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typeBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0; }
  40% { transform: scale(1); opacity: 1; }
}
.streaming-active {
  transform: translateZ(0);
  box-shadow: 0 12px 42px rgba(0,0,0,0.14),
              0 0 0 1px color-mix(in srgb, var(--accent) 22%, var(--glass-border)),
              inset 0 1px 0 var(--glass-shine);
}
@keyframes liquidBreath {
  0%, 100% { transform: scale(1); box-shadow: 0 12px 32px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.05); }
  50% { transform: scale(1.025); box-shadow: 0 18px 44px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.12); }
}
.msg-bubble h1,.msg-bubble h2,.msg-bubble h3 {
  font-size: 1em; font-weight: 700; margin: .6em 0 .3em;
}
.msg-bubble p { margin: .3em 0; }
.msg-bubble p:first-child { margin-top: 0; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 1.4em; margin: .4em 0; }
.msg-bubble li { margin: .2em 0; }
.msg-bubble code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .85em; background: rgba(255,255,255,.06);
  padding: 2px 5px; border-radius: 4px;
}
.msg-row.user .msg-bubble code { background: rgba(0,0,0,.2); }
.msg-bubble pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px;
  overflow-x: auto; margin: .6em 0;
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble em { opacity: .85; }
.msg-bubble blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 10px; margin: .4em 0;
  color: var(--text2);
}

/* Streaming cursor */
.stream-cursor::after {
  content: '▋';
  animation: blink .7s step-end infinite;
  color: var(--accent);
  font-size: .85em;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── Chat welcome / no-messages state ─────────────────── */
.chat-welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh;
  text-align: center; padding: 40px 20px;
  gap: 14px;
}
.chat-welcome-avatar {
  width: 72px; height: 72px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; overflow: hidden; margin-bottom: 4px;
}
.chat-welcome-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-welcome-name { font-size: 20px; font-weight: 700; }
.chat-welcome-desc { font-size: 13px; color: var(--text2); max-width: 340px; line-height: 1.6; }
.chat-welcome-tags { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }

/* ── Input Area ────────────────────────────────────────── */
.chat-input-wrap {
  flex-shrink: 0;
  padding: 14px 20px 22px;
  background: transparent;
  position: relative;
}

.chat-input-wrap::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 150px;
  background: linear-gradient(to top, var(--bg) 35%, transparent);
  pointer-events: none;
  z-index: -1;
}

.chat-input-container { max-width: 760px; margin: 0 auto; position: relative; }

/* Liquid Glass input box */
.chat-input-box {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25),
              inset 0 1px 0 var(--glass-shine),
              inset 0 -1px 0 rgba(0,0,0,0.06);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
  overflow: hidden;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  position: relative;
}
/* Top-edge glass shine line */
.chat-input-box::before {
  content: '';
  position: absolute; top: 0; left: 16px; right: 16px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
  pointer-events: none; z-index: 1;
}
.chat-input-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--glass-border));
  box-shadow: 0 8px 36px rgba(0,0,0,0.28),
              0 0 0 2px var(--accent-lo),
              inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-2px);
}

.chat-input-box textarea {
  width: 100%; border: none; outline: none;
  background: transparent; resize: none;
  font-family: inherit; font-size: 14px; color: var(--text);
  padding: 14px 16px 4px; line-height: 1.6;
  max-height: 160px; overflow-y: auto;
}
.chat-input-box textarea::placeholder { color: var(--muted); }

.chat-input-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px 10px;
}
.chat-input-actions-left { display: flex; gap: 4px; align-items: center; flex: 1; min-width: 0; }
.chat-input-actions-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.chat-input-hint {
  margin-top: 7px;
  font-size: 10.5px; color: var(--muted);
  text-align: center;
}

.chat-attach-preview {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 0;
}
.chat-attach-preview.has-items { display: flex; }

.chat-attach-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.chat-attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-attach-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-input-vision-hint {
  display: none;
  font-size: 10.5px;
  color: var(--yellow, #c9a227);
  padding: 0 16px 6px;
}
.chat-input-vision-hint.visible {
  display: block;
  animation: hintFlash 1.4s ease both;
}

@keyframes hintFlash {
  0% { opacity: 0; transform: translateY(3px); }
  12% { opacity: 1; transform: translateY(0); }
  78% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-2px); }
}

.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.msg-images img {
  max-width: min(240px, 100%);
  max-height: 180px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: cover;
  cursor: pointer;
}

/* ── Debug Panel ───────────────────────────────────────── */
.debug-panel {
  position: fixed; bottom: 20px; right: 20px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r-lg); padding: 14px;
  width: 240px; font-size: 11px;
  box-shadow: var(--shadow-lg);
  display: none;
}
.debug-panel.open { display: block; }
.debug-title { font-weight: 700; margin-bottom: 8px; font-size: 12px; }
.debug-key-row {
  display: flex; gap: 6px; align-items: center;
  padding: 3px 0; color: var(--text2);
}
.debug-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.debug-dot.active { background: var(--green); }
.debug-dot.cooling { background: var(--yellow); }
.debug-dot.dead { background: var(--red); }

/* ══════════════════════════════════════════════════════════
   CREATOR PAGE
   ══════════════════════════════════════════════════════════ */

.creator-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  max-width: 960px; margin: 0 auto;
  padding: 0 20px;
}

.creator-form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
}

.creator-preview-section {
  position: sticky; top: calc(var(--navbar-h) + 20px);
  height: fit-content;
}

.creator-section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── Form Elements ─────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text2); margin-bottom: 7px;
}
.form-label .required { color: var(--accent2); }

.form-input, .form-textarea, .form-select {
  width: 100%; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; font-family: inherit; font-size: 13.5px;
  color: var(--text); outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  appearance: none;
}
.form-select {
  background-image: url('data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><polyline points="6 9 12 15 18 9"></polyline></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 32px;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-lo);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--muted); }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form-select { cursor: pointer; }
.form-select, .period-select {
  color-scheme: inherit;
}
select option {
  background-color: var(--bg);
  color: var(--text);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Avatar Upload ─────────────────────────────────────── */
.avatar-upload-area {
  display: flex; align-items: center; gap: 16px;
  padding: 14px; background: var(--bg2);
  border: 1px dashed var(--border2); border-radius: var(--r);
  transition: border-color var(--t);
  cursor: pointer;
}
.avatar-upload-area:hover { border-color: var(--accent); }

.avatar-preview {
  width: 60px; height: 60px; border-radius: 14px;
  overflow: hidden; flex-shrink: 0;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-upload-info { flex: 1; }
.avatar-upload-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.avatar-upload-sub { font-size: 11px; color: var(--muted); }
.avatar-upload-btns { display: flex; gap: 6px; margin-top: 8px; }

/* ── Color Picker ──────────────────────────────────────── */
.color-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.color-swatch {
  width: 26px; height: 26px; border-radius: 8px;
  cursor: pointer; border: 2px solid transparent;
  transition: transform var(--t), border-color var(--t);
  flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); }
input[type="color"].form-input {
  padding: 4px 8px; height: 38px; cursor: pointer;
}

/* ── Preview Card ──────────────────────────────────────── */
.preview-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); overflow: hidden;
}
.preview-card-top {
  height: 4px; background: var(--accent);
  transition: background .2s;
}
.preview-card-body { padding: 20px; }
.preview-char-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.preview-avatar {
  width: 50px; height: 50px; border-radius: 13px;
  overflow: hidden; display: flex; align-items: center;
  justify-content: center; font-size: 26px; flex-shrink: 0;
}
.preview-avatar img { width: 100%; height: 100%; object-fit: cover; }
.preview-name { font-size: 16px; font-weight: 700; }
.preview-model { font-size: 11px; color: var(--muted); margin-top: 2px; }
.preview-desc { font-size: 12.5px; color: var(--text2); line-height: 1.5; margin-bottom: 10px; }
.preview-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 16px; }
.preview-greeting {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px;
  font-size: 12.5px; color: var(--text2); line-height: 1.5;
  font-style: italic;
}
.preview-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.creator-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.creator-quick-card {
  position: relative;
  overflow: hidden;
  min-height: 64px;
  padding: 12px;
  border-radius: var(--r);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.creator-quick-card::before,
.creator-chat-demo::before,
.bot-profile-shell::before,
.bot-profile-chat::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, var(--glass-shine), transparent 38%);
  opacity: .7;
}
.creator-quick-card span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.creator-quick-card strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  line-height: 1.2;
}
.creator-quick-card.is-active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--glass-border));
  box-shadow: var(--glass-shadow), 0 0 24px var(--accent-lo);
}
.creator-advanced {
  border: 1px solid var(--glass-border);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--glass-bg) 80%, transparent);
  margin-bottom: 14px;
  overflow: hidden;
}
.creator-advanced summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.creator-advanced summary small {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-align: right;
}
.creator-advanced > .form-group {
  padding: 0 14px 14px;
  margin-bottom: 0;
}
.creator-chat-demo {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  background: var(--glass-bg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  overflow: hidden;
}
.creator-demo-msg,
.bot-chat-msg {
  position: relative;
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.45;
  animation: messageFloatIn .36s cubic-bezier(.16,1,.3,1) both;
}
.creator-demo-msg.bot,
.bot-chat-msg.bot {
  align-self: flex-start;
  color: var(--text2);
  background: rgba(255,255,255,.07);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine);
}
.creator-demo-msg.user,
.bot-chat-msg.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 20px var(--accent-lo);
  animation-name: userMessageFloatIn;
}
.creator-demo-typing,
.bot-chat-typing {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 10px 12px;
  border-radius: 99px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.06);
}
.creator-demo-typing span,
.bot-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typeBounce 1.25s infinite ease-in-out;
}
.creator-demo-typing span:nth-child(2),
.bot-chat-typing span:nth-child(2) { animation-delay: .15s; }
.creator-demo-typing span:nth-child(3),
.bot-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes messageFloatIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes userMessageFloatIn {
  from { opacity: 0; transform: translate(12px, 10px) scale(.98); }
  to { opacity: 1; transform: translate(0, 0) scale(1); }
}

/* ── Danger Zone ───────────────────────────────────────── */
.danger-zone {
  margin-top: 24px; padding: 16px;
  background: #f8717108; border: 1px solid #f8717120;
  border-radius: var(--r);
}
.danger-title { font-size: 12px; font-weight: 700; color: var(--red); margin-bottom: 8px; }

/* ══════════════════════════════════════════════════════════
   PROFILE & AUTH
   ══════════════════════════════════════════════════════════ */
.profile-page { padding-top: calc(var(--navbar-h) + 16px); }
.profile-container { max-width: 720px; margin: 0 auto; }

.profile-hero {
  position: relative;
  text-align: center;
  padding: 32px 20px 24px;
  margin-bottom: 20px;
}
.profile-hero-bg {
  position: absolute;
  inset: 0;
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, var(--profile-color, var(--accent)) 0%, transparent 70%);
  opacity: .25;
  pointer-events: none;
}
.profile-avatar-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  overflow: hidden;
  border: 2px solid var(--border2);
}
.profile-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.profile-handle { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.profile-creator { color: var(--text2); font-size: 13px; }
.profile-creator-link { color: var(--accent); text-decoration: none; }
.profile-creator-link:hover { text-decoration: underline; }
.char-creator-link { color: var(--accent); text-decoration: none; font-size: inherit; }
.char-creator-link:hover { text-decoration: underline; }
.profile-desc { color: var(--text2); line-height: 1.6; margin-bottom: 14px; text-align: center; }
.profile-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 18px; }
.profile-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 18px 0;
}
.profile-stat { text-align: center; }
.profile-stat-val { display: block; font-size: 20px; font-weight: 700; }
.profile-stat-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.profile-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}
.profile-greeting {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 16px;
}
.profile-greeting-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; }
.profile-trending-badge {
  display: inline-block;
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--yellow);
}
.profile-tabs {
  display: flex;
  gap: 6px;
  margin: 24px 0 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.profile-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color var(--t), border-color var(--t);
}
.profile-tab:hover { color: var(--text); }
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.profile-empty { text-align: center; color: var(--muted); padding: 32px 0; }
.profile-works-grid { margin-top: 8px; }

.bot-profile-shell {
  position: relative;
  overflow: hidden;
  padding: 22px;
  margin-bottom: 22px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  background: var(--glass-bg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.bot-profile-glow {
  position: absolute;
  inset: -35% -20% auto auto;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--profile-color, var(--accent)) 38%, transparent);
  filter: blur(70px);
  pointer-events: none;
}
.bot-profile-main {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
}
.bot-profile-avatar {
  margin: 0;
  width: 112px;
  height: 112px;
  border-radius: 28px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28), 0 0 0 1px var(--glass-border);
}
.bot-profile-copy {
  min-width: 0;
  text-align: left;
}
.bot-profile-kicker {
  min-height: 24px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.bot-profile-copy .profile-name {
  font-size: 32px;
  line-height: 1.1;
  margin-bottom: 8px;
}
.bot-profile-copy .profile-desc {
  text-align: left;
  margin: 12px 0;
}
.bot-profile-copy .profile-tags {
  justify-content: flex-start;
  margin-bottom: 0;
}
.bot-profile-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0 14px;
}
.bot-profile-stats .profile-stat {
  padding: 12px;
  border-radius: var(--r);
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.055);
}
.bot-profile-chat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  margin-top: 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: color-mix(in srgb, var(--bg2) 65%, transparent);
  overflow: hidden;
}
.bot-profile-actions {
  position: relative;
  justify-content: stretch;
  margin-top: 16px;
}
.bot-profile-actions .profile-like {
  min-width: 76px;
  justify-content: center;
}

.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--t);
}
.user-list-item:hover { border-color: var(--accent); }
.user-list-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.user-list-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-list-name { font-weight: 600; font-size: 14px; }
.user-list-handle { font-size: 12px; color: var(--muted); }
.user-edit-panel { margin-bottom: 20px; }

.nav-auth-user { display: flex; align-items: center; gap: 4px; position: relative; }
.nav-auth-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-lo);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--border);
}
.nav-auth-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav-auth-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-auth-dropdown[hidden] { display: none !important; }
.nav-auth-dropdown a,
.nav-auth-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.nav-auth-dropdown a:hover,
.nav-auth-dropdown button:hover { background: var(--surface2); }
.auth-setup-hint { color: var(--muted); font-size: 14px; cursor: help; }
.auth-coming-soon:disabled { opacity: 0.55; cursor: not-allowed; }
.nav-auth-slot { display: flex; align-items: center; flex-shrink: 0; }
.nav-auth-user { flex-shrink: 0; }
.auth-login-btn { display: inline-flex; align-items: center; gap: 6px; }

.guest-limit-banner {
  display: none;
  max-width: 740px;
  margin: 0 auto 8px;
  padding: 8px 12px;
  font-size: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  text-align: center;
}
.guest-limit-banner.visible { display: block; }
.guest-limit-banner.blocked {
  border-color: var(--accent);
  background: var(--accent-lo);
  color: var(--accent);
}
.guest-limit-modal .login-google-btn { width: 100%; justify-content: center; }

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--navbar-h));
  padding: 24px;
}
.login-card {
  max-width: 400px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px;
  text-align: center;
}
.login-logo { font-size: 42px; font-weight: 850; margin-bottom: 30px; text-decoration: none; display: flex; justify-content: center; align-items: center; gap: 14px; }
.login-logo img { width: 72px !important; height: 72px !important; border-radius: 16px; }
.login-logo svg, .login-logo .nixa-logo-svg {
  width: 76px !important;
  height: 76px !important;
  filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.65));
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.35s ease;
  display: block;
}
.login-logo:hover svg, .login-logo:hover .nixa-logo-svg {
  transform: scale(1.1) rotate(-4deg);
  filter: drop-shadow(0 0 28px rgba(139, 92, 246, 0.95));
}
.login-logo span { color: inherit; }
.login-card h1 { font-size: 22px; margin-bottom: 8px; }
.login-sub { color: var(--text2); font-size: 14px; margin-bottom: 24px; line-height: 1.5; }
.login-google-btn { width: 100%; justify-content: center; gap: 10px; }
.login-setup {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text2);
  text-align: left;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .chat-sidebar { display: none; }
  .creator-layout { grid-template-columns: 1fr; }
  .creator-preview-section { position: static; }
  .navbar { padding: 0 12px; }
  .navbar-links { gap: 6px; }
  .navbar-links .btn-ghost:not(.btn-icon) { display: none; }
  span[data-i18n="nav_create"] { display: none; }
  .search-bar { width: 140px !important; }
  .char-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .search-bar { display: none !important; }
  /* .navbar-logo span { display: none; } -- removed so brand name does not truncate on mobile */
  .char-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .profile-hero {
    padding: 20px 12px 16px;
  }
  .profile-avatar-wrap {
    width: 80px;
    height: 80px;
    border-radius: 20px;
  }
  .profile-name {
    font-size: 21px;
  }
  .profile-stats {
    gap: 14px;
    margin: 14px 0;
  }
  .profile-stat-val {
    font-size: 17px;
  }
  .profile-stat-lbl {
    font-size: 10px;
  }
  .profile-tab {
    padding: 8px 10px;
    font-size: 12px;
  }
  .creator-quick-grid {
    grid-template-columns: 1fr;
  }
  .bot-profile-shell {
    padding: 16px;
  }
  .bot-profile-main {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .bot-profile-avatar {
    margin: 0 auto;
    width: 88px;
    height: 88px;
    border-radius: 22px;
  }
  .bot-profile-copy,
  .bot-profile-copy .profile-desc {
    text-align: center;
  }
  .bot-profile-copy .profile-name {
    font-size: 24px;
  }
  .bot-profile-copy .profile-tags {
    justify-content: center;
  }
  .bot-profile-stats {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }
}

/* ── Chat provider badge ───────────────────────────────── */
.chat-provider-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--accent);
  background: var(--accent-lo);
  white-space: nowrap;
}
.chat-provider-badge.byok {
  color: var(--text2);
  background: var(--surface2);
}

/* ══════════════════════════════════════════════════════════
   REASONING / THINKING BLOCK — Brain Animation Only
   (content is intentionally hidden from the user)
   ══════════════════════════════════════════════════════════ */
.thinking-block {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 2px 0;
  padding: 10px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  font-size: 12.5px;
  color: var(--muted);
  opacity: 0;
  animation: thinkingAppear 0.4s ease forwards;
}
@keyframes thinkingAppear {
  to { opacity: 1; }
}

/* Brain icon — pulsing glow */
.thinking-brain-icon {
  font-size: 20px;
  animation: brainPulse 1.6s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(168,85,247,0.5));
  flex-shrink: 0;
}
@keyframes brainPulse {
  0%, 100% { transform: scale(1);   filter: drop-shadow(0 0 4px rgba(168,85,247,0.35)); }
  50%       { transform: scale(1.18); filter: drop-shadow(0 0 14px rgba(168,85,247,0.85)); }
}

/* Thinking dots */
.thinking-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.thinking-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent2);
  animation: thinkDot 1.4s infinite both;
}
.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinkDot {
  0%, 80%, 100% { transform: scale(0); opacity: 0; }
  40%           { transform: scale(1); opacity: 1; }
}

/* Hide the header, chevron and body — only the animation wrapper is shown */
.thinking-header { display: none !important; }
.thinking-chevron { display: none !important; }
.thinking-body { display: none !important; }

/* ── World Info Panel ──────────────────────────────────── */
.world-info-panel {
  position: fixed;
  right: 0; top: var(--navbar-h); bottom: 0;
  width: 300px;
  background: color-mix(in srgb, var(--bg2) 80%, transparent);
  border-left: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  display: flex; flex-direction: column;
  z-index: 90;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -8px 0 32px rgba(0,0,0,0.18);
}
.world-info-panel.open { transform: translateX(0); }
.world-info-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.world-info-body { flex: 1; padding: 14px; overflow-y: auto; }
.world-info-body textarea {
  width: 100%; min-height: 200px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  color: var(--text); font-family: 'JetBrains Mono', monospace;
  font-size: 12px; line-height: 1.6;
  padding: 10px 12px; resize: vertical;
  outline: none;
  transition: border-color var(--t);
}
.world-info-body textarea:focus { border-color: var(--accent); }
.world-info-desc {
  font-size: 11px; color: var(--muted); line-height: 1.5;
  margin-bottom: 10px;
}
.world-info-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

/* ── Context indicator in status bar ──────────────────── */
.ctx-indicator {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--muted);
}
.ctx-bar {
  width: 60px; height: 4px;
  border-radius: 99px;
  background: var(--surface3);
  overflow: hidden;
}
.ctx-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.5s ease;
}

/* ── Draft indicator ───────────────────────────────────── */
.draft-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--muted);
  padding: 2px 7px; border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--border);
  margin-right: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.draft-badge.visible { opacity: 1; }

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.provider-btn {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  text-align: center;
  transition: border-color var(--t), color var(--t), background var(--t);
  line-height: 1.35;
  font-family: inherit;
}
.provider-btn:hover { border-color: var(--accent); color: var(--text); }
.provider-btn.selected { border-color: var(--accent); background: var(--accent-lo); color: var(--accent); }
.provider-model-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* Reasoning button active state */
.btn.reasoning-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Trust Banner & Info Cards ────────────────────────── */
.trust-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: -10px auto 36px;
  max-width: 900px;
}
.trust-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  transition: transform var(--t), border-color var(--t);
}
.trust-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent)55;
}
.trust-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-lo);
  color: var(--accent);
  font-size: 20px;
  flex-shrink: 0;
}
.trust-body {
  flex: 1;
}
.trust-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.trust-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 768px) {
  .trust-row {
    grid-template-columns: 1fr;
    margin-bottom: 24px;
  }
}

/* RTL Specific Rules to prevent broken layouts in Arabic */
html[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
html[dir="rtl"] .navbar-spacer {
  margin-right: auto;
  margin-left: initial;
}
html[dir="rtl"] .trust-card {
  text-align: right;
  flex-direction: row;
}
html[dir="rtl"] .featured-char-row,
html[dir="rtl"] .char-card-header,
html[dir="rtl"] .profile-hero,
html[dir="rtl"] .navbar,
html[dir="rtl"] .chat-input-row,
html[dir="rtl"] .creator-form-section {
  text-align: right;
}
html[dir="rtl"] .lang-switcher {
  direction: ltr; /* keep language tabs consistent */
}
html[dir="rtl"] .navbar-links {
  margin-right: auto;
  margin-left: initial;
}
html[dir="rtl"] .char-stats {
  justify-content: flex-start;
}
html[dir="rtl"] .btn svg {
  margin-right: 0px;
  margin-left: 6px;
}

/* ══════════════════════════════════════════════════════════
   RTL — дополнительные исправления
   ══════════════════════════════════════════════════════════ */
html[dir="rtl"] .chat-sidebar {
  left: auto;
  right: 0;
  border-left: none;
  border-right: 1px solid var(--border);
}
html[dir="rtl"] .world-info-panel {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--glass-border);
  transform: translateX(-100%);
}
html[dir="rtl"] .world-info-panel.open {
  transform: translateX(0);
}
html[dir="rtl"] .toast-container {
  left: 16px;
  right: auto;
}
html[dir="rtl"] .sidebar-no-chats,
html[dir="rtl"] .msg-bubble {
  text-align: right;
}

/* ══════════════════════════════════════════════════════════
   MOBILE UX — Полный блок адаптивности
   ══════════════════════════════════════════════════════════ */

/* Все интерактивные элементы — минимум 44px touch target */
@media (max-width: 768px) {
  .btn            { min-height: 40px; padding: 8px 16px; }
  .btn-icon       { min-width: 40px; min-height: 40px; }

  /* Navbar — компакт */
  .navbar         { height: 60px; padding: 0 12px; gap: 8px; }
  .navbar-logo    { font-size: 17px; gap: 6px; }
  .navbar-logo img,
  .navbar-logo svg { width: 26px; height: 26px; }

  /* Скрыть текстовые пункты навигации */
  .navbar-links .btn-ghost:not(.btn-icon) { display: none; }
  span[data-i18n="nav_create"] { display: none; }
  .search-bar     { width: 140px !important; }

  /* Chat — инпут фиксирован снизу, не перекрывается клавиатурой */
  .chat-wrap      { height: calc(100dvh - 60px); }
  .chat-messages  { padding-bottom: 90px; }
  .chat-input-area {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    padding: 8px 12px env(safe-area-inset-bottom, 8px);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-top: 1px solid var(--border);
  }

  /* World info — на весь экран на мобилке */
  .world-info-panel { width: 100%; top: 60px; }

  /* Sidebar скрыт */
  .chat-sidebar   { display: none; }

  /* Status bar компакт */
  .chat-status-bar { font-size: 11px; padding: 4px 12px; }
  .ctx-indicator  { display: none; }

  /* Модальные окна — fit screen */
  .modal-box {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 48px);
    margin: 24px 12px;
    border-radius: 16px;
    overflow-y: auto;
  }

  /* Character grid — 2 col */
  .char-grid      { grid-template-columns: 1fr 1fr; }

  /* Creator */
  .creator-layout { grid-template-columns: 1fr; gap: 16px; }
  .creator-preview-section { position: static; }
  .form-row       { grid-template-columns: 1fr; }

  /* Trust section */
  .trust-row      { grid-template-columns: 1fr; margin-bottom: 24px; }

  /* Hero */
  .hero-title     { font-size: clamp(24px, 6vw, 42px); }
  .hero-sub       { font-size: 14px; }

  /* Explore how-steps */
  .how-steps      { flex-direction: column; gap: 16px; }
  .how-step       { width: 100%; }

  /* Category grid */
  .cat-grid       { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cat-card       { padding: 14px 12px; }
  .cat-card-icon  { font-size: 24px; }
  .cat-card-title { font-size: 13px; }

  /* Profile */
  .profile-hero       { padding: 20px 12px 16px; }
  .profile-avatar-wrap{ width: 80px; height: 80px; border-radius: 20px; }
  .profile-name       { font-size: 21px; }
  .profile-stats      { gap: 14px; margin: 14px 0; }
  .profile-stat-val   { font-size: 17px; }
  .profile-stat-lbl   { font-size: 10px; }
  .profile-tab        { padding: 8px 12px; font-size: 12px; min-height: 40px; }

  /* Settings */
  .settings-container { padding: 16px 12px; }
  .settings-section   { padding: 16px; border-radius: 14px; }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
  .search-bar     { display: none !important; }
  .char-grid      { grid-template-columns: 1fr; }
  .navbar         { padding: 0 10px; }

  /* Пузыри чата — почти на весь экран */
  .msg-bubble     { max-width: 96%; }

  /* Input */
  .chat-input-wrap textarea { font-size: 15px; }

  /* Категории — 1 колонка */
  .cat-grid       { grid-template-columns: 1fr; }

  /* Карточки персонажей — горизонтально */
  .char-card          { flex-direction: row; gap: 10px; padding: 12px; }
  .char-card-avatar   { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; }
  .char-card-body     { flex: 1; min-width: 0; }
  .char-card-desc     { display: none; }
  .char-card-footer   { display: none; }

  /* Лого бренда не обрезается */
  .navbar-logo span {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Safe-area insets для iPhone notch/home-indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-input-area {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .navbar {

/* ══════════════════════════════════════════════════════════
   RTL — дополнительные исправления
   ══════════════════════════════════════════════════════════ */
html[dir="rtl"] .chat-sidebar {
  left: auto;
  right: 0;
  border-left: none;
  border-right: 1px solid var(--border);
}
html[dir="rtl"] .world-info-panel {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--glass-border);
  transform: translateX(-100%);
}
html[dir="rtl"] .world-info-panel.open {
  transform: translateX(0);
}
html[dir="rtl"] .toast-container {
  left: 16px;
  right: auto;
}
html[dir="rtl"] .sidebar-no-chats,
html[dir="rtl"] .msg-bubble {
  text-align: right;
}

/* ══════════════════════════════════════════════════════════
   MOBILE UX — Полный блок адаптивности
   ══════════════════════════════════════════════════════════ */

/* Все интерактивные элементы — минимум 44px touch target */
@media (max-width: 768px) {
  .btn            { min-height: 40px; padding: 8px 16px; }
  .btn-icon       { min-width: 40px; min-height: 40px; }

  /* Navbar — компакт */
  .navbar         { height: 60px; padding: 0 12px; gap: 8px; }
  .navbar-logo    { font-size: 17px; gap: 6px; }
  .navbar-logo img,
  .navbar-logo svg { width: 26px; height: 26px; }

  /* Скрыть текстовые пункты навигации */
  .navbar-links .btn-ghost:not(.btn-icon) { display: none; }
  span[data-i18n="nav_create"] { display: none; }
  .search-bar     { width: 140px !important; }

  /* Chat — инпут фиксирован снизу, не перекрывается клавиатурой */
  .chat-wrap      { height: calc(100dvh - 60px); }
  .chat-messages  { padding-bottom: 90px; }
  .chat-input-area {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    padding: 8px 12px env(safe-area-inset-bottom, 8px);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-top: 1px solid var(--border);
  }

  /* World info — на весь экран на мобилке */
  .world-info-panel { width: 100%; top: 60px; }

  /* Sidebar скрыт */
  .chat-sidebar   { display: none; }

  /* Status bar компакт */
  .chat-status-bar { font-size: 11px; padding: 4px 12px; }
  .ctx-indicator  { display: none; }

  /* Модальные окна — fit screen */
  .modal-box {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 48px);
    margin: 24px 12px;
    border-radius: 16px;
    overflow-y: auto;
  }

  /* Character grid — 2 col */
  .char-grid      { grid-template-columns: 1fr 1fr; }

  /* Creator */
  .creator-layout { grid-template-columns: 1fr; gap: 16px; }
  .creator-preview-section { position: static; }
  .form-row       { grid-template-columns: 1fr; }

  /* Trust section */
  .trust-row      { grid-template-columns: 1fr; margin-bottom: 24px; }

  /* Hero */
  .hero-title     { font-size: clamp(24px, 6vw, 42px); }
  .hero-sub       { font-size: 14px; }

  /* Explore how-steps */
  .how-steps      { flex-direction: column; gap: 16px; }
  .how-step       { width: 100%; }

  /* Category grid */
  .cat-grid       { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cat-card       { padding: 14px 12px; }
  .cat-card-icon  { font-size: 24px; }
  .cat-card-title { font-size: 13px; }

  /* Profile */
  .profile-hero       { padding: 20px 12px 16px; }
  .profile-avatar-wrap{ width: 80px; height: 80px; border-radius: 20px; }
  .profile-name       { font-size: 21px; }
  .profile-stats      { gap: 14px; margin: 14px 0; }
  .profile-stat-val   { font-size: 17px; }
  .profile-stat-lbl   { font-size: 10px; }
  .profile-tab        { padding: 8px 12px; font-size: 12px; min-height: 40px; }

  /* Settings */
  .settings-container { padding: 16px 12px; }
  .settings-section   { padding: 16px; border-radius: 14px; }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
  .search-bar     { display: none !important; }
  .char-grid      { grid-template-columns: 1fr; }
  .navbar         { padding: 0 10px; }

  /* Пузыри чата — почти на весь экран */
  .msg-bubble     { max-width: 96%; }

  /* Input */
  .chat-input-wrap textarea { font-size: 15px; }

  /* Категории — 1 колонка */
  .cat-grid       { grid-template-columns: 1fr; }

  /* Карточки персонажей — горизонтально */
  .char-card          { flex-direction: row; gap: 10px; padding: 12px; }
  .char-card-avatar   { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; }
  .char-card-body     { flex: 1; min-width: 0; }
  .char-card-desc     { display: none; }
  .char-card-footer   { display: none; }

  /* Лого бренда не обрезается */
  .navbar-logo span {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Safe-area insets для iPhone notch/home-indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-input-area {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .navbar {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

/* Landscape на мобилке */
@media (max-width: 768px) and (orientation: landscape) {
  .chat-input-area  { padding: 6px 12px; }
  .chat-wrap        { height: calc(100dvh - 52px); }
  .world-info-panel { top: 52px; }
  .navbar           { height: 52px; }
}

/* ══════════════════════════════════════════════════════════
   NIXA v3 — Enhanced Liquid Glass, Typing & Profile
   ══════════════════════════════════════════════════════════ */

/* ── Liquid Bounce Typing Dots (global) ─────────────────── */
@keyframes liquidBounce {
  0%, 80%, 100% { transform: scale(0.5) translateY(0);  opacity: 0.3; }
  40%           { transform: scale(1.1) translateY(-6px); opacity: 1; }
}
/* Override old typeBounce dots everywhere */
.creator-demo-typing span,
.bot-chat-typing span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  animation: liquidBounce 1.25s infinite ease-in-out;
}
.creator-demo-typing span:nth-child(2),
.bot-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.creator-demo-typing span:nth-child(3),
.bot-chat-typing span:nth-child(3) { animation-delay: 0.36s; }

/* Thinking dots — enhanced colors */
.thinking-dots span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  animation: liquidBounce 1.3s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }

/* Typing indicator row (chat — before bot responds) */
.typing-indicator-row {
  display: flex; gap: 12px; padding: 6px 0;
  animation: fadeInUp .3s cubic-bezier(0.16,1,0.3,1);
}
.typing-indicator-row .ti-bubble {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 12px 18px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px 20px 20px 6px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-shine), 0 4px 12px rgba(0,0,0,.1);
}
.ti-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  animation: liquidBounce 1.2s infinite ease-in-out;
}
.ti-dot:nth-child(2) { animation-delay: 0.18s; }
.ti-dot:nth-child(3) { animation-delay: 0.36s; }

/* User typing animation in input */
.chat-input-box.user-typing {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--glass-border));
  box-shadow: 0 8px 36px rgba(0,0,0,.28),
              0 0 0 2px var(--accent-lo),
              inset 0 1px 0 rgba(255,255,255,.14);
}
.chat-input-box.user-typing textarea {
  caret-color: var(--accent);
}

/* User-typing label next to input (shows "typing…") */
.user-typing-label {
  font-size: 10.5px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  margin-right: 4px;
}
.user-typing-label.visible { opacity: 1; }

/* ── Typewriter cursor class ────────────────────────────── */
.typewriter-active {
  border-right: 1.5px solid var(--accent);
  animation: twCursor 0.7s step-end infinite;
}
@keyframes twCursor {
  0%, 100% { border-color: var(--accent); }
  50%       { border-color: transparent; }
}

/* ── Streaming bubble — enhanced pulse ──────────────────── */
.streaming-active {
  transform: translateZ(0);
  box-shadow: 0 12px 42px rgba(0,0,0,.14),
              0 0 0 1px color-mix(in srgb, var(--accent) 25%, var(--glass-border)),
              inset 0 1px 0 var(--glass-shine);
  animation: streamPulse 2s ease-in-out infinite;
}
@keyframes streamPulse {
  0%, 100% { box-shadow: 0 12px 42px rgba(0,0,0,.14),
              0 0 0 1px color-mix(in srgb, var(--accent) 25%, var(--glass-border)),
              inset 0 1px 0 var(--glass-shine); }
  50%      { box-shadow: 0 16px 52px rgba(0,0,0,.18),
              0 0 0 1px color-mix(in srgb, var(--accent) 45%, var(--glass-border)),
              inset 0 1px 0 var(--glass-shine),
              0 0 24px var(--accent-lo); }
}

/* ── Message row — smoother entrance ───────────────────── */
@keyframes msgSlideIn {
  0%   { opacity: 0; transform: translateY(10px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0)   scale(1); }
}
.msg-row {
  animation: msgSlideIn .38s cubic-bezier(0.16,1,0.3,1) both;
}
.msg-row.user { animation-name: msgSlideInUser; }
@keyframes msgSlideInUser {
  0%   { opacity: 0; transform: translate(12px, 10px) scale(0.97); }
  100% { opacity: 1; transform: translate(0, 0)       scale(1); }
}

/* ══════════════════════════════════════════════════════════
   BOT PROFILE — Redesigned Premium Card
   ══════════════════════════════════════════════════════════ */

/* Shell: full-width liquid glass hero */
.bot-profile-shell-v2 {
  position: relative; overflow: hidden;
  padding: 28px 24px 20px;
  margin-bottom: 24px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  background: var(--glass-bg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  animation: pageFadeIn 0.5s cubic-bezier(0.16,1,0.3,1);
}
/* Top-edge glass shine */
.bot-profile-shell-v2::before {
  content: '';
  position: absolute; top: 0; left: 20px; right: 20px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
  pointer-events: none;
}
/* Color glow at top */
.bot-profile-banner {
  position: absolute;
  inset: 0 0 auto 0;
  height: 140px;
  background: linear-gradient(180deg, var(--profile-color, var(--accent)), transparent);
  opacity: 0.14;
  pointer-events: none;
}
/* Ambient glow orb */
.bot-profile-orb {
  position: absolute;
  top: -60px; right: -40px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--profile-color, var(--accent)) 0%, transparent 70%);
  opacity: 0.22;
  filter: blur(40px);
  pointer-events: none;
  animation: orbFloat 6s ease-in-out infinite;
}
@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(-10px, 12px) scale(1.06); }
}

/* Avatar — large with ring */
.bot-profile-av-v2 {
  position: relative;
  width: 100px; height: 100px;
  border-radius: 26px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  box-shadow: 0 0 0 2px var(--glass-border),
              0 20px 48px rgba(0,0,0,.32),
              0 0 40px color-mix(in srgb, var(--profile-color, var(--accent)) 30%, transparent);
  transition: box-shadow 0.4s ease;
  animation: avatarPop 0.55s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes avatarPop {
  0%   { opacity: 0; transform: scale(0.7) rotate(-6deg); }
  100% { opacity: 1; transform: scale(1)   rotate(0deg); }
}
.bot-profile-av-v2 img { width: 100%; height: 100%; object-fit: cover; }
.bot-profile-av-v2:hover {
  box-shadow: 0 0 0 2px var(--profile-color, var(--accent)),
              0 24px 56px rgba(0,0,0,.38),
              0 0 50px color-mix(in srgb, var(--profile-color, var(--accent)) 50%, transparent);
}

/* Main grid */
.bot-profile-grid-v2 {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

/* Copy area */
.bot-profile-info { min-width: 0; }
.bot-profile-kicker {
  font-size: 11.5px; color: var(--muted); margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.bot-profile-name-v2 {
  font-size: 28px; font-weight: 800; line-height: 1.1;
  letter-spacing: -.5px;
  margin-bottom: 6px;
  background: linear-gradient(to right, var(--text) 60%, var(--muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.bot-profile-creator-v2 {
  font-size: 12.5px; color: var(--muted); margin-bottom: 10px;
}
.bot-profile-desc-v2 {
  font-size: 13.5px; color: var(--text2); line-height: 1.6;
  margin-bottom: 12px;
}
.bot-profile-tags-v2 { display: flex; flex-wrap: wrap; gap: 6px; }

/* Stats row */
.bot-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 16px;
}
.bot-stat-card {
  position: relative;
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  text-align: center;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.bot-stat-card:hover {
  border-color: color-mix(in srgb, var(--profile-color, var(--accent)) 50%, var(--glass-border));
  box-shadow: 0 0 16px color-mix(in srgb, var(--profile-color, var(--accent)) 15%, transparent);
}
.bot-stat-val {
  display: block;
  font-size: 22px; font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--text2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.bot-stat-lbl {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-top: 2px;
}

/* Chat preview inside profile */
.bot-profile-chat-v2 {
  display: flex; flex-direction: column; gap: 9px;
  padding: 14px;
  margin-bottom: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.12);
  overflow: hidden;
}
.bot-profile-chat-msg-bot {
  align-self: flex-start; max-width: 90%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px 14px 14px 5px;
  padding: 10px 14px;
  font-size: 13px; line-height: 1.55; color: var(--text2);
  box-shadow: inset 0 1px 0 var(--glass-shine);
  animation: msgSlideIn 0.4s cubic-bezier(0.16,1,0.3,1) both;
}
.bot-profile-chat-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-radius: 14px 14px 5px 14px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 6px 20px var(--accent-lo);
  animation: msgSlideInUser 0.4s cubic-bezier(0.16,1,0.3,1) 0.15s both;
}
.bot-profile-typing-v2 {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 10px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 99px;
  animation: msgSlideIn 0.4s cubic-bezier(0.16,1,0.3,1) 0.3s both;
}
.bot-profile-typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  animation: liquidBounce 1.25s infinite ease-in-out;
}
.bot-profile-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.bot-profile-typing-dot:nth-child(3) { animation-delay: 0.36s; }

/* Actions row */
.bot-profile-acts-v2 {
  display: flex; gap: 10px; align-items: center;
}
.bot-profile-acts-v2 .chat-btn-full {
  flex: 1; justify-content: center;
}
.bot-like-btn-v2 {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--glass-bg);
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
.bot-like-btn-v2:hover { border-color: #f472b6; color: #f472b6; background: rgba(244,114,182,0.08); }
.bot-like-btn-v2.liked { border-color: #f472b6; color: #f472b6; background: rgba(244,114,182,0.1); }
.bot-like-icon-v2 { font-size: 16px; }

/* Trending badge */
.trending-badge-v2 {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  background: rgba(251,191,36,0.12);
  border: 1px solid rgba(251,191,36,0.3);
  color: var(--yellow);
  font-size: 11px; font-weight: 600;
}

/* Visibility badge */
.vis-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px; font-weight: 500;
}

@media (max-width: 480px) {
  .bot-profile-grid-v2 { grid-template-columns: 1fr; text-align: center; }
  .bot-profile-av-v2   { margin: 0 auto; width: 84px; height: 84px; }
  .bot-profile-tags-v2 { justify-content: center; }
  .bot-profile-name-v2 { font-size: 22px; }
  .bot-stats-row       { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .bot-stat-val        { font-size: 18px; }
  .bot-profile-acts-v2 { flex-wrap: wrap; }
  .bot-profile-acts-v2 .chat-btn-full { width: 100%; }
}

/* ── Page performance: will-change hints ─────────────────── */
.msg-row,
.char-card,
.history-item,
.btn {
  will-change: transform;
}
/* Reduce blur on low-power devices */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
