/* ============================================================
   CharVerse — Main Stylesheet
   Aesthetic: Dark cosmic, neon accents, editorial typographie
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #080b12;
  --bg2:       #0d1120;
  --bg3:       #131826;
  --border:    rgba(255,255,255,0.07);
  --border-h:  rgba(255,255,255,0.14);
  --text:      #e8eaf2;
  --text-dim:  #7a7f96;
  --text-faint:#3d4156;
  --accent:    #7c6dfa;
  --accent2:   #fa6d9a;
  --accent3:   #6dfacc;
  --glow:      rgba(124,109,250,0.35);
  --glow2:     rgba(250,109,154,0.25);
  --radius:    14px;
  --radius-lg: 22px;
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --nav-h:     64px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 99px; }

/* ---- CONTAINER ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ===== NAVBAR ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: rgba(8,11,18,0.85);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.navbar__inner {
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; gap: 32px;
}
.navbar__logo {
  font-family: var(--font-head);
  font-weight: 800; font-size: 20px;
  color: var(--text); text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.navbar__logo span { color: var(--accent); }
.navbar__logo svg { width: 28px; height: 28px; }
.navbar__links { display: flex; gap: 4px; margin-right: auto; }
.navbar__links a {
  color: var(--text-dim); text-decoration: none;
  padding: 6px 14px; border-radius: 8px; font-size: 14px;
  font-weight: 500; transition: all .2s;
}
.navbar__links a:hover { color: var(--text); background: var(--bg3); }
.navbar__links a.active { color: var(--text); background: var(--bg3); }
.navbar__user { display: flex; align-items: center; gap: 12px; }
.navbar__avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  text-decoration: none; overflow: hidden; border: 2px solid var(--border);
}
.navbar__avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px; border-radius: 10px;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  text-decoration: none; border: none; cursor: pointer;
  transition: all .25s; white-space: nowrap;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 24px var(--glow);
}
.btn--primary:hover {
  background: #9182ff; transform: translateY(-1px);
  box-shadow: 0 0 36px var(--glow);
}
.btn--ghost {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn--ghost:hover { color: var(--text); border-color: var(--border-h); background: var(--bg3); }
.btn--danger { background: rgba(250,80,80,0.15); color: #fa5050; border: 1px solid rgba(250,80,80,0.2); }
.btn--danger:hover { background: rgba(250,80,80,0.25); }
.btn--sm { padding: 7px 16px; font-size: 13px; }
.btn--lg { padding: 14px 30px; font-size: 16px; }
.btn--full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ===== HERO ===== */
.hero {
  position: relative; overflow: hidden;
  padding: calc(var(--nav-h) + 80px) 0 80px;
  text-align: center;
}
.hero__noise {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}
.hero__orbs { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .5;
  animation: drift 12s ease-in-out infinite alternate;
}
.orb--1 { width: 500px; height: 500px; background: var(--accent); top: -200px; left: -100px; animation-delay: 0s; }
.orb--2 { width: 400px; height: 400px; background: var(--accent2); top: -150px; right: -100px; animation-delay: -4s; }
.orb--3 { width: 300px; height: 300px; background: var(--accent3); bottom: -100px; left: 50%; animation-delay: -8s; }
@keyframes drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(30px,20px) scale(1.05); }
}
.hero__inner { position: relative; z-index: 1; }
.hero__badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(124,109,250,0.12); border: 1px solid rgba(124,109,250,0.3);
  color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .08em;
  padding: 5px 14px; border-radius: 99px; text-transform: uppercase; margin-bottom: 24px;
}
.hero__title {
  font-family: var(--font-head); font-size: clamp(48px, 8vw, 88px);
  font-weight: 800; line-height: 1.05; letter-spacing: -.03em; margin-bottom: 20px;
  background: linear-gradient(135deg, #fff 30%, var(--text-dim));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero__title em { font-style: normal; -webkit-text-fill-color: var(--accent); }
.hero__sub { font-size: 18px; color: var(--text-dim); max-width: 560px; margin: 0 auto 36px; font-weight: 300; }
.hero__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 48px; }
.hero__stats { display: flex; gap: 48px; justify-content: center; flex-wrap: wrap; }
.stat { text-align: center; }
.stat span { display: block; font-family: var(--font-head); font-size: 32px; font-weight: 800; color: var(--text); }
.stat label { font-size: 12px; color: var(--text-dim); letter-spacing: .06em; text-transform: uppercase; }

/* ===== FILTERS ===== */
.explore { padding: 60px 0; }
.filters { margin-bottom: 40px; display: flex; flex-direction: column; gap: 16px; }
.search-box {
  position: relative; max-width: 480px;
}
.search-box svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; stroke: var(--text-dim); fill: none;
  stroke-width: 2; stroke-linecap: round;
}
.search-box input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px 10px 42px;
  color: var(--text); font-family: var(--font-body); font-size: 14px;
  outline: none; transition: border-color .2s;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-faint); }
.filters__tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--text-dim); text-decoration: none; border: 1px solid var(--border);
  transition: all .2s; background: transparent;
}
.tab:hover { color: var(--text); border-color: var(--border-h); }
.tab--active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filters__sort { display: flex; gap: 8px; }
.sort-btn {
  padding: 6px 14px; border-radius: 8px; font-size: 13px;
  color: var(--text-dim); text-decoration: none; border: 1px solid var(--border);
  transition: all .2s;
}
.sort-btn.active { color: var(--text); border-color: var(--border-h); background: var(--bg3); }

/* ===== CHARS GRID ===== */
.chars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.char-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column;
  transition: all .25s; cursor: pointer;
}
.char-card:hover {
  border-color: var(--border-h); transform: translateY(-3px);
  box-shadow: 0 12px 36px rgba(0,0,0,.4);
}
.char-card__avatar {
  position: relative; aspect-ratio: 1; overflow: hidden;
  background: linear-gradient(135deg, var(--bg3), var(--bg));
}
.char-card__avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-card__initials {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 48px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.char-card__badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(8,11,18,0.8); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 99px;
  font-size: 10px; padding: 3px 10px; color: var(--text-dim);
  text-transform: capitalize;
}
.char-card__body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.char-card__name { font-family: var(--font-head); font-size: 15px; font-weight: 700; }
.char-card__tagline { font-size: 12px; color: var(--text-dim); flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.char-card__meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-faint); margin-top: 8px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 80px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.empty-state__icon { font-size: 56px; }
.empty-state h3 { font-family: var(--font-head); font-size: 22px; }
.empty-state p { color: var(--text-dim); }

/* ===== CTA BAND ===== */
.cta-band {
  padding: 80px 0; margin-top: 40px;
  background: linear-gradient(135deg, rgba(124,109,250,.1), rgba(250,109,154,.1));
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.cta-band__inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.cta-band h2 { font-family: var(--font-head); font-size: 36px; font-weight: 800; }
.cta-band p { color: var(--text-dim); font-size: 16px; }

/* ===== FORMS ===== */
.form-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--nav-h) + 40px) 24px 60px;
}
.form-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px;
  width: 100%; max-width: 460px;
}
.form-card h1 { font-family: var(--font-head); font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.form-card .subtitle { color: var(--text-dim); margin-bottom: 32px; font-size: 14px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: var(--text-dim); letter-spacing: .04em; text-transform: uppercase; }
.form-control {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 14px;
  color: var(--text); font-family: var(--font-body); font-size: 14px;
  outline: none; transition: border-color .2s; resize: vertical;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-faint); }
select.form-control option { background: var(--bg3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.form-divider { text-align: center; margin: 20px 0; color: var(--text-faint); font-size: 13px; position: relative; }
.form-divider::before, .form-divider::after {
  content: ''; position: absolute; top: 50%; width: calc(50% - 24px); height: 1px; background: var(--border);
}
.form-divider::before { left: 0; }
.form-divider::after { right: 0; }
.form-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.form-link:hover { text-decoration: underline; }

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 20px;
  border: 1px solid;
}
.alert--error { background: rgba(250,80,80,.1); border-color: rgba(250,80,80,.2); color: #fa8080; }
.alert--success { background: rgba(109,250,204,.1); border-color: rgba(109,250,204,.2); color: var(--accent3); }

/* ===== CHAR CREATE ===== */
.page-layout {
  padding: calc(var(--nav-h) + 40px) 0 60px;
}
.page-header { margin-bottom: 40px; }
.page-header h1 { font-family: var(--font-head); font-size: 36px; font-weight: 800; margin-bottom: 8px; }
.page-header p { color: var(--text-dim); }
.create-grid { display: grid; grid-template-columns: 1fr 360px; gap: 32px; align-items: start; }
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
}
.card h2 { font-family: var(--font-head); font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.avatar-upload {
  width: 120px; height: 120px; border-radius: 50%;
  border: 2px dashed var(--border); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--text-faint); font-size: 12px;
  overflow: hidden; transition: border-color .2s;
  margin: 0 auto 24px;
}
.avatar-upload:hover { border-color: var(--accent); }
.avatar-upload img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.visibility-radios { display: flex; gap: 10px; }
.vis-radio { flex: 1; }
.vis-radio input { display: none; }
.vis-radio label {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; font-size: 13px; color: var(--text-dim); transition: all .2s;
  text-align: center;
}
.vis-radio label .vis-icon { font-size: 24px; }
.vis-radio input:checked + label { border-color: var(--accent); color: var(--accent); background: rgba(124,109,250,.08); }
.section-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 12px; margin-top: 24px; }

/* ===== PROFILE ===== */
.profile-header {
  padding: calc(var(--nav-h) + 40px) 0 0;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  border-bottom: 1px solid var(--border); margin-bottom: 40px;
}
.profile-hero { display: flex; gap: 28px; align-items: flex-end; padding-bottom: 32px; }
.profile-avatar {
  width: 100px; height: 100px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 42px; font-weight: 800;
  color: #fff; overflow: hidden; border: 3px solid var(--border); flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { flex: 1; }
.profile-info h1 { font-family: var(--font-head); font-size: 32px; font-weight: 800; }
.profile-info .bio { color: var(--text-dim); margin-top: 6px; }
.profile-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.profile-tab {
  padding: 12px 20px; font-size: 14px; font-weight: 500;
  color: var(--text-dim); text-decoration: none; border-bottom: 2px solid transparent;
  transition: all .2s; margin-bottom: -1px;
}
.profile-tab:hover { color: var(--text); }
.profile-tab.active { color: var(--text); border-color: var(--accent); }

/* ===== CHAT ===== */
.chat-page {
  display: flex; height: 100vh; padding-top: var(--nav-h);
  overflow: hidden;
}
.chat-sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-sidebar__head {
  padding: 20px 16px; border-bottom: 1px solid var(--border);
}
.chat-char-info { display: flex; gap: 12px; align-items: center; }
.chat-char-avatar {
  width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 22px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.chat-char-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-char-name { font-family: var(--font-head); font-weight: 700; font-size: 16px; }
.chat-char-tag { font-size: 12px; color: var(--text-dim); }
.chat-sidebar__desc {
  padding: 16px; font-size: 13px; color: var(--text-dim); border-bottom: 1px solid var(--border);
  overflow-y: auto; flex: 1;
}
.chat-sidebar__actions { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.msg { display: flex; gap: 12px; max-width: 75%; animation: msgIn .3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.msg--user { align-self: flex-end; flex-direction: row-reverse; }
.msg__avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  overflow: hidden; background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}
.msg__avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg__bubble {
  padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.6;
}
.msg--char .msg__bubble { background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg--user .msg__bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg__name { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.msg--user .msg__name { text-align: right; }
.chat-input-area { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg); }
.chat-input-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px; color: var(--text);
  font-family: var(--font-body); font-size: 14px; outline: none;
  resize: none; max-height: 160px; transition: border-color .2s;
  line-height: 1.5;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-faint); }
.chat-send {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .2s;
}
.chat-send:hover { background: #9182ff; }
.chat-send svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }
.typing-indicator { display: flex; gap: 4px; align-items: center; padding: 12px 16px; }
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce { 0%,80%,100% { transform: scale(0.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-dim); }
.chat-empty .big { font-size: 64px; }
.chat-empty h3 { font-family: var(--font-head); font-size: 20px; color: var(--text); }

/* ===== CONVERSATIONS LIST ===== */
.conv-list { display: flex; flex-direction: column; gap: 8px; }
.conv-item {
  display: flex; gap: 12px; align-items: center; padding: 12px;
  border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; color: inherit; transition: all .2s;
  background: var(--bg2);
}
.conv-item:hover { border-color: var(--border-h); background: var(--bg3); }
.conv-avatar {
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 18px; font-weight: 800;
  color: #fff; flex-shrink: 0;
}
.conv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conv-info h4 { font-size: 14px; font-weight: 600; }
.conv-info p { font-size: 12px; color: var(--text-dim); }

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--border); padding: 40px 0;
  text-align: center; color: var(--text-faint); font-size: 13px;
}
.footer a { color: var(--text-dim); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .create-grid { grid-template-columns: 1fr; }
  .chat-sidebar { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .hero__stats { gap: 28px; }
  .chars-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ===== UTILS ===== */
.text-accent { color: var(--accent); }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.char-manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 24px; }
.char-manage-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.char-manage-card__top { display: flex; gap: 12px; padding: 16px; align-items: center; }
.char-manage-card__actions { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.badge {
  display: inline-flex; padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.badge--public { background: rgba(109,250,204,.1); color: var(--accent3); border: 1px solid rgba(109,250,204,.2); }
.badge--private { background: rgba(250,80,80,.1); color: #fa8080; border: 1px solid rgba(250,80,80,.2); }
