/* ourgirls.ai frontend styles — palette and card language follow candy.ai */
:root {
  /* surfaces (candy.ai: --co-bg / --clr-bg / --co-panel-2 / --co-panel-3) */
  --bg: #09090a;
  --surface: #171717;
  --surface-2: #19191c;
  --surface-3: #212125;
  --stage: #101012;

  --border: #ffffff1f;
  --border-strong: #ffffff2e;
  --line: #ffffff12;

  --text: #f2f2f3;
  --muted: #a1a1aa;
  --dim: #6b6b73;

  /* brand (candy.ai: --primary-color) */
  --pink: #f97187;
  --pink-hover: #fc768a;
  --pink-deep: #e65073;
  --hot: #ff356e;
  --gold: #fcbb00;

  --radius: 16px;
  --radius-sm: 12px;
  --pill: 999px;
  --sidebar-w: 232px;

  --font: "Poppins", sans-serif;
}

* { box-sizing: border-box; touch-action: manipulation; }

html, body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* iOS Safari force-zooms the viewport when you focus a field whose
   font-size is below 16px. Keep every field at 16px or larger. */
input, textarea, select { font-size: 16px; }

button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #ffffff29; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #ffffff47; }
::-webkit-scrollbar-track { background: transparent; }

/* App shell: fixed to the dynamic viewport so the page itself never grows.
   Each view owns its own scroll container instead. */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------------- sidebar ---------------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.logo-mark { width: 28px; height: 28px; display: block; flex: 0 0 auto; }
.brand-name { font-weight: 600; letter-spacing: -0.2px; flex: 1; font-size: 15px; }
.collapse { color: var(--dim); }
.collapse svg { width: 18px; height: 18px; }
.menu-btn svg { width: 32px; height: 32px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav.sub { margin-top: 8px; padding-top: 8px; border-top: 1px solid #ffffff14; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 8px;
  border-radius: 12px;
  color: #f4f4f5;
  text-align: left;
  width: 100%;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
}
.nav-ico { width: 22px; height: 22px; flex: 0 0 auto; }
.nav-item:hover { background: #ffffff0d; }
.nav-item.active { background: #ffffff10; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 10px; }
.premium-item { color: #f0b429; }
.premium-item .off {
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}
.drawer-links {
  margin: 4px 8px 0;
  color: #6f6f78;
  font-size: 12px;
  font-weight: 500;
}
.drawer-links button { color: inherit; font-weight: 500; }
.drawer-links button:hover { color: var(--text); }

/* ---------------- main column ---------------- */
.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* Views scroll internally. The chat view is the exception: its log scrolls
   while the header and composer stay put, so the page never resizes. */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
#view-chat { overflow: hidden; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.filters { display: contents; }
.sitebar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
}
.menu-btn,
.sitebar-brand { display: none; }
.sitebar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.findbar { display: contents; }
.find-scroll { display: contents; }
.select-wrap { position: relative; flex: 0 0 auto; }
.select-wrap select {
  appearance: none;
  padding: 9px 30px 9px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  transition: border-color .15s, background .15s;
}
.select-wrap select:hover { border-color: var(--border-strong); }
.select-wrap::after {
  content: "⌄";
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-58%);
  color: var(--dim);
  pointer-events: none;
}

.search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 40px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: var(--border-strong); background: var(--surface-3); }
.search-icon { color: var(--dim); font-size: 15px; }
.search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
}
.search input::placeholder { color: var(--dim); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { color: var(--dim); font-size: 12px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}
.icon-btn:hover { background: #ffffff14; color: var(--text); }
.back-btn { width: 44px; height: 44px; color: #fff; }
.back-btn svg { width: 28px; height: 28px; }
.icon-btn.ghost:hover { color: var(--pink); }

/* tag chips */
.chips {
  display: flex;
  gap: 8px;
  flex: 1 0 100%;
  padding: 2px 0 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 8px 15px;
  border-radius: var(--pill);
  background: var(--surface-3);
  color: var(--text);
  white-space: nowrap;
  border: 1px solid transparent;
  font-size: 13px;
}
.chip:hover { background: var(--surface-2); border-color: var(--border); }
.chip.active {
  background: #f971871f;
  border-color: var(--pink);
  color: var(--text);
  font-weight: 600;
}
.chip-all {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.chip-all.active {
  background: var(--pink);
  border-color: transparent;
  color: #2a0118;
}

/* homepage carousel */
.hero { padding: 4px 0 2px; }
.hero-track {
  position: relative;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 14px;
  scrollbar-width: none;
}
.hero-track::-webkit-scrollbar { display: none; }
.hero-slide {
  position: relative;
  flex: 0 0 min(420px, 86%);
  height: 168px;
  scroll-snap-align: start;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(115deg, #3a1824 0%, #1a1218 55%, #121214 100%);
  color: #fff;
  text-align: left;
}
.hero-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}
.hero-photo:not([src]) { display: none; }
.hero-slide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #09090ae6 0%, #09090a8c 42%, #09090a22 100%);
}
.hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
  padding: 18px 18px 20px;
}
.hero-copy b {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.05;
}
.hero-copy em { font-style: normal; font-weight: 600; font-size: 14px; }
.hero-dots { display: flex; justify-content: center; gap: 6px; padding: 10px 0 2px; }
.hero-dots i { width: 6px; height: 6px; border-radius: 99px; background: #ffffff33; display: block; }
.hero-dots i.on { width: 16px; background: #fff; }

.hubs {
  display: flex;
  align-items: flex-end;
  gap: 22px;
  padding: 8px 20px 0;
}
.hub {
  position: relative;
  padding: 8px 2px 10px;
  color: #8d8d96;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  background: none;
}
.hub.on { color: #fff; }
.hub.on::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--pink);
}

/* character grid */
.grid-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 14px;
}
.grid-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;
}
.grid-head h2 em { font-style: normal; color: var(--pink); }
.grid-head span { color: var(--dim); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 16px 12px;
  padding: 0 20px 24px;
}

/* Character card — name and age sit on the image itself, candy.ai style. */
.card { display: block; text-align: left; min-width: 0; }

.card-thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* permanent scrim so the name always stays readable */
.card-scrim {
  position: absolute;
  inset: auto 0 0 0;
  padding: 36px 12px 11px;
  background: linear-gradient(to top, #000000e6 14%, #0000008c 50%, transparent);
}
.card-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 1px 6px #000000b3;
}
.card-name .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-name .ag { flex: 0 0 auto; font-weight: 400; color: #ffffffd9; }
.card-stats {
  display: flex;
  gap: 10px;
  margin-top: 3px;
  font-size: 12px;
  color: #ffffffa6;
}

.card-noimg {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--dim);
  font-size: 24px;
}
.card-play {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 3px 8px;
  border-radius: var(--pill);
  background: #000000a6;
  backdrop-filter: blur(6px);
  font-size: 11px;
  color: #fff;
}

.grid-foot { display: grid; place-items: center; padding: 6px 20px 40px; }
.more {
  padding: 12px 28px;
  border-radius: var(--pill);
  background: var(--surface-3);
  color: var(--text);
  font-weight: 600;
  border: 1px solid var(--line);
}
.more:hover { background: var(--surface-2); border-color: var(--border-strong); }
.end { color: var(--dim); margin: 0; }

.skeleton { border-radius: var(--radius); background: var(--surface-2); aspect-ratio: 3 / 4; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ---------------- chat ---------------- */
.chat-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
}
.chat-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.chat-avatar-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}
.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  pointer-events: none;
}
.chat-who {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  line-height: 1.25;
  min-width: 0;
  flex: 1;
  padding: 0;
  color: inherit;
  text-align: left;
}
.chat-who b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-who span { color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.persona {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: #00000073;
}
.persona[hidden] { display: none; }
.persona-card {
  position: relative;
  width: min(420px, 100%);
  max-height: min(78vh, 680px);
  overflow: auto;
  padding: 28px 22px 22px;
  border-radius: 22px;
  background: #161618;
  border: 1px solid #ffffff14;
  text-align: center;
}
.persona-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  color: var(--muted);
  font-size: 18px;
}
.persona-avatar {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}
.persona-avatar[hidden] { display: none; }
.persona-card h2 { margin: 14px 0 6px; font-size: 22px; font-weight: 600; }
.persona-meta { margin: 0; color: var(--muted); font-size: 13px; }
.persona-bio, .persona-personality {
  margin: 14px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  text-align: left;
  white-space: pre-wrap;
}
.persona-kicker {
  margin: 16px 0 0;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-align: left;
  text-transform: uppercase;
}
.persona-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.msg {
  max-width: 76%;
  padding: 11px 14px;
  border-radius: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant { align-self: flex-start; background: #2a2a2e; border-radius: 18px; }
.msg.user { align-self: flex-end; background: #f97187; color: #2d1a1f; border-radius: 18px; }
.msg.error { align-self: center; background: #3f1d1d; color: #fca5a5; font-size: 13px; max-width: 90%; }

.thought {
  align-self: flex-start;
  max-width: 76%;
  margin: 2px 0 12px;
  padding-left: 12px;
  border-left: 2px solid #ffffff24;
  color: #a08a96;
  font-size: 13px;
  font-style: italic;
  line-height: 1.6;
  white-space: pre-wrap;
}

.msg-img { align-self: flex-start; max-width: 300px; border-radius: var(--radius); display: block; }

.typing { display: flex; gap: 4px; align-self: flex-start; padding: 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.composer {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0;
  margin: 0 auto 8px;
  width: min(860px, calc(100% - 20px));
  padding: 0 0 calc(8px + env(safe-area-inset-bottom));
  background: transparent;
}
.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 160px;
  padding: 12px 10px 12px 16px;
  border-radius: 24px 0 0 24px;
  background: #1c1c20;
  border: 0;
  resize: none;
  outline: none;
  line-height: 1.5;
  /* Must stay >= 16px: iOS Safari zooms the whole page when focusing
     an input whose font-size is smaller than that. */
  font-size: 16px;
}
.ask {
  position: relative;
  display: flex;
  align-items: center;
  align-self: stretch;
  min-height: 48px;
  padding: 0 10px 0 4px;
  border-radius: 0 24px 24px 0;
  background: #1c1c20;
  flex: 0 0 auto;
}
.ask-go {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 8px 0 10px;
  border-radius: 999px;
  color: #f2f2f3;
  font-weight: 600;
  font-size: 14px;
}
.ask-go svg { width: 16px; height: 16px; color: var(--pink); }

/* chat list */
.chats-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 auto;
  padding: 18px 16px 4px;
  max-width: 860px;
  width: 100%;
}
.chats-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: 0; line-height: 1.2; }
#chats-close { margin-left: auto; }
.chat-list { display: flex; flex-direction: column; margin: 0 auto; padding: 4px 8px 40px; max-width: 860px; width: 100%; }
.chat-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 12px;
  text-align: left;
  width: 100%;
  cursor: pointer;
}
.chat-row:hover { background: #ffffff0c; }
.chat-row img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.chat-row .meta b { display: block; font-size: 14px; font-weight: 600; }
.chat-row .meta span { color: var(--dim); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-side { display: grid; justify-items: end; gap: 8px; color: var(--dim); }
.chat-actions { display: flex; gap: 2px; }
.chat-actions button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #8d8d95;
  border-radius: 8px;
}
.chat-actions button:hover { background: #ffffff14; color: var(--text); }
.chat-actions svg { width: 16px; height: 16px; }

.blank { display: grid; place-items: center; gap: 10px; padding: 80px 20px; text-align: center; }
.blank h2 { margin: 0; }
.blank p { color: var(--dim); margin: 0; }

/* lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #000000e6;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.lightbox-close { position: absolute; top: 18px; right: 22px; font-size: 22px; color: #fff; }
.lightbox-body { display: flex; gap: 12px; overflow-x: auto; max-width: 100%; padding: 8px; }
.lightbox-body img { height: 72vh; border-radius: var(--radius); object-fit: contain; background: var(--surface); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  z-index: 95;
  padding: 11px 18px;
  border-radius: 10px;
  background: var(--surface-3);
  box-shadow: 0 8px 30px #00000080;
  font-size: 13px;
}

/* mobile tab bar */
.tabbar {
  display: none;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 60;
  width: min(460px, calc(100vw - 20px));
  justify-content: space-between;
  gap: 2px;
  padding: 8px 8px 10px;
  border-radius: 28px;
  border: 1px solid #ffffff14;
  background: rgba(22, 22, 24, 0.78);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.tab { flex: 1; min-width: 0; padding: 4px 0 2px; display: grid; place-items: center; gap: 3px; color: #b9b9c1; border-radius: 16px; }
.tab svg { width: 22px; height: 22px; }
.tab span { font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; }
.tab[data-nav="create"] svg { width: 26px; height: 26px; }
.tab.active { color: var(--pink); }
.tab-premium { color: #f0b429; }

.scrim { position: fixed; inset: 0; z-index: 70; background: #00000080; }
.ghost-pill, .join-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
}
.ghost-pill { border: 1px solid #ffffff38; color: #fff; }
.join-pill { background: var(--pink); color: #2a0118; font-weight: 700; }
.coin-pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #fcbb001f;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}
.chat-coins { height: 28px; padding: 0 10px; font-size: 12px; }
.auth-coins { margin: -8px 0 6px; color: var(--gold); font-weight: 700; }
.auth-invite { margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.4px; }
.auth-interest { margin: 0 0 16px; color: var(--muted); font-size: 13px; font-weight: 600; }

.ledger { margin: 0 0 14px; }
.ledger h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ledger ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 148px;
  overflow-y: auto;
}
.ledger li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13px; }
.ledger .meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ledger .note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger .when { color: var(--dim); font-size: 12px; }
.ledger .amt { flex: 0 0 auto; font-weight: 700; }
.ledger .amt.plus { color: var(--gold); }
.ledger .amt.minus { color: #fca5a5; }
.ledger .empty { color: var(--dim); }

/* ---------------- shared controls ---------------- */
.primary {
  padding: 13px 26px;
  border-radius: var(--pill);
  font-weight: 600;
  color: #2d1a1f;
  background: var(--pink);
}
.primary:hover { background: var(--pink-hover); }
.primary:disabled { opacity: 0.55; cursor: default; }
.primary.wide { width: 100%; }
.small-btn { padding: 7px 14px; font-size: 13px; margin-left: auto; }

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--pill);
  background: var(--surface-2);
}
.seg-item {
  flex: 1;
  padding: 11px 12px;
  border-radius: var(--pill);
  color: var(--muted);
  white-space: nowrap;
}
.seg-item:hover { color: var(--text); }
.seg-item.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.seg.small .seg-item { padding: 8px 10px; font-size: 13px; }
.seg-item.disabled { opacity: 0.4; cursor: default; }

/* ---------------- create wizard ---------------- */
.wizard {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 20px 72px;
}
.wiz-top {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}
.wiz-progress { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.wiz-progress span { color: var(--dim); font-size: 12px; text-align: center; letter-spacing: 0.4px; }
.wiz-bar { height: 3px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.wiz-bar i { display: block; height: 100%; width: 0; background: var(--pink); border-radius: inherit; }
.wiz-kicker {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.wizard-title {
  margin: 2px 0 8px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.4px;
  line-height: 1.15;
}
.wizard-title span { color: var(--pink); }
.wiz-hint { margin: 0 0 18px; text-align: center; color: var(--dim); font-size: 13px; }

.wiz-pills, .wiz-tiles, .wiz-swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.wiz-pill, .wiz-tile {
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 2px solid transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.wiz-pill.on, .wiz-tile.on, .wiz-portrait.on, .wiz-swatch.on { border-color: var(--pink); }
.wiz-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
.wiz-tile { text-align: center; }

.wiz-portraits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.wiz-portrait {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid transparent;
  background: var(--surface-2);
  color: #fff;
  padding: 0;
}
.wiz-portrait img, .wiz-portrait .ph { width: 100%; height: 100%; object-fit: cover; display: block; }
.wiz-portrait .ph { background: linear-gradient(160deg, #2a2a32, #121216 70%); }
.wiz-portrait::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46%;
  background: linear-gradient(transparent, #000000d6);
  pointer-events: none;
}
.wiz-portrait b {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 12px;
  z-index: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 2px 10px #000000cc;
}

.wiz-swatch {
  width: 72px;
  padding: 8px 0 10px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.wiz-swatch i {
  display: block;
  width: 36px;
  height: 36px;
  margin: 0 auto 6px;
  border-radius: 50%;
  border: 1px solid #ffffff22;
}

.wizard label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.wizard input[type="text"],
.wizard input[type="number"],
.wizard input:not([type]),
.wizard textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text);
  outline: none;
  resize: vertical;
  font-size: 16px;
}
.wizard input:focus, .wizard textarea:focus { border-color: var(--border-strong); }
.wiz-summary { margin: 0 0 16px; color: var(--dim); font-size: 13px; line-height: 1.5; text-align: center; }

.avatar-row { display: flex; gap: 16px; align-items: flex-start; margin: 4px 0 22px; }
.avatar-preview {
  width: 96px;
  height: 120px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--dim);
  font-size: 22px;
  overflow: hidden;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-ctl { flex: 1; min-width: 0; }
.avatar-ctl .hint { margin: 0 0 10px; color: var(--dim); font-size: 13px; line-height: 1.5; }
.avatar-btns { display: flex; gap: 8px; }
.file-btn {
  display: inline-block !important;
  margin: 0 !important;
  padding: 11px 18px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.file-btn:hover { background: var(--surface-3); }

/* ---------------- generate ---------------- */
.gen-wrap { display: flex; gap: 22px; align-items: flex-start; padding: 20px; flex: 1; min-height: 0; }
.gen-panel {
  flex: 0 0 340px;
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.gen-subtabs { display: flex; gap: 16px; font-size: 13px; }
.gen-subtabs b { color: var(--text); }
.gen-subtabs span { color: var(--dim); }
.gen-label { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preset {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 22px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}
.preset:hover { border-color: var(--pink); color: var(--text); }
.preset.active { border-color: var(--pink); background: #f9718714; color: var(--text); }
.preset.done { border-color: var(--pink); }
.preset i { font-style: normal; font-size: 20px; }
.preset b { font-size: 15px; font-weight: 600; color: var(--text); }
.preset span { font-size: 12px; color: var(--dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset.done span { color: var(--pink); }

.preset-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
}
.opt {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
}
.opt:hover { color: var(--text); }
.opt.active { background: var(--pink); color: #2a0118; font-weight: 600; }

.gen-panel textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text);
  outline: none;
  resize: vertical;
  font-size: 16px;
}
.gen-panel textarea:focus { border-color: var(--border-strong); }
.gen-foot { margin-top: auto; padding-top: 6px; }
.cost { opacity: 0.75; font-weight: 500; }

.gen-main { flex: 1; min-width: 0; }
.gen-main h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
}
.gen-main h2 em { font-style: normal; color: var(--pink); }
.gen-sub { margin: 0 0 16px; color: var(--dim); font-size: 13px; }
.gen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.gen-grid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.gen-grid img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  background: var(--surface-2);
  display: block;
  cursor: pointer;
}
.gen-grid figcaption { color: var(--dim); font-size: 12px; }
.gen-empty {
  grid-column: 1 / -1;
  padding: 30px;
  border-radius: 14px;
  border: 1px dashed var(--border-strong);
  color: var(--dim);
  text-align: center;
  line-height: 1.7;
}

/* ---------------- my ai ---------------- */
.myai { padding: 20px 0 60px; }
.myai .grid-head { padding-left: 20px; padding-right: 20px; }
.myai .grid { padding: 0 20px 20px; }
.my-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 0 20px 20px;
}
.my-gallery img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}
.my-gallery .gen-empty { grid-column: 1 / -1; }

.mine-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 3px 9px;
  border-radius: var(--pill);
  background: var(--pink);
  color: #2d1a1f;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

/* ---------------- character picker ---------------- */
.picker {
  position: fixed;
  inset: 0;
  z-index: 92;
  background: #000000cc;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.picker-box {
  width: min(1000px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.picker-box header { display: flex; gap: 10px; padding: 14px; border-bottom: 1px solid var(--border); }
.picker-box header input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text);
  outline: none;
}
.picker-box .grid { overflow-y: auto; padding: 16px; }

/* ---------------- responsive ---------------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar {
    display: flex;
    position: fixed;
    z-index: 80;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; }
  .tabbar { display: flex; }
  .main { padding-bottom: 96px; }
  body.in-chat .tabbar { display: none; }
  body.in-chat .main { padding-bottom: 0; }
  .topbar { padding: 10px 12px 12px; gap: 10px; }
  .sitebar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  .menu-btn, .sitebar-brand, .sitebar-actions { display: flex; }
  .menu-btn { display: grid; place-items: center; width: 40px; height: 40px; color: #fff; }
  .sidebar {
    width: min(300px, 84vw);
    background: #141416;
    border-right: 0;
    padding: 18px 16px 20px;
    box-shadow: 18px 0 48px #00000099;
  }
  .sitebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    min-width: 0;
  }
  .sitebar-brand .logo-mark { width: 34px; height: 34px; }
  .sitebar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sitebar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
  .gender-wrap select {
    background: transparent;
    padding: 4px 18px 4px 2px;
  }
  .findbar { display: flex; align-items: center; gap: 8px; width: 100%; }
  .find-scroll {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .find-scroll::-webkit-scrollbar { display: none; }
  .filters { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
  .chips { flex: 0 0 auto; padding: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 10px; padding: 0 14px 20px; }
  .hubs { gap: 0; justify-content: space-between; padding: 6px 16px 0; }
  .hub { font-size: 15px; }
  .grid-head { padding: 4px 14px 10px; }
  .grid-foot { padding-bottom: 26px; }
  .log { padding: 16px 14px 8px; }
  .composer { width: calc(100% - 16px); padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .msg, .thought { max-width: 88%; }
  .chat-head { padding: 8px 14px; }
  .chat-list { padding: 6px 8px 30px; }

  .wizard { padding: 14px 14px 48px; }
  .wizard-title { font-size: 28px; }
  .wiz-portraits { gap: 10px; }
  .avatar-row { flex-direction: column; }

  .gen-wrap { flex-direction: column; padding: 14px; gap: 16px; }
  .gen-panel { position: static; flex: 1 1 auto; width: 100%; }
  .gen-main h2 { font-size: 20px; }
  .gen-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .myai .grid-head, .myai .grid, .my-gallery { padding-left: 14px; padding-right: 14px; }
  .picker { padding: 16px; }
}

@media (min-width: 861px) {
  .grid-head h2 { font-size: 22px; }
  .sidebar.collapsed { flex-basis: 74px; width: 74px; }
  .sidebar.collapsed .brand-name,
  .sidebar.collapsed .nav-item span,
  .sidebar.collapsed .premium-item .off,
  .sidebar.collapsed .drawer-links { display: none; }
  .sidebar.collapsed .nav-item { justify-content: center; gap: 0; }
}

/* ---------------- auth ---------------- */
.auth {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(12px, env(safe-area-inset-top))
    12px
    max(12px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #000000a6;
  backdrop-filter: blur(8px);
}
.auth-card {
  position: relative;
  width: min(420px, 100%);
  max-width: 100%;
  margin: auto;
  flex: 0 0 auto;
  padding: 26px 22px 18px;
  border-radius: 18px;
  background: #161618;
  border: 1px solid #ffffff14;
  box-shadow: 0 24px 60px #00000080;
}
.auth-x {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  font-size: 18px;
}
.auth-card h2 { margin: 0 0 18px; font-size: 22px; font-weight: 600; letter-spacing: 0; }
.auth-field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  margin-bottom: 10px;
  padding: 0 12px;
  border-radius: 12px;
  background: #232328;
  color: var(--dim);
}
.auth-field input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  font-size: 16px;
  color: var(--text);
  scroll-margin: 96px;
}
.field-ico, .auth-eye {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  padding: 0;
}
.field-ico svg, .auth-eye svg { width: 20px; height: 20px; display: block; }
.social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  font-weight: 400;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}
.social-ico { width: 24px; height: 24px; flex: 0 0 auto; display: block; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.auth-links button { color: var(--text); font-size: 14px; line-height: 1.35; text-decoration: underline; text-underline-offset: 3px; text-align: left; }
.auth-hint { margin: -2px 0 12px; color: var(--dim); font-size: 13px; }
.auth-error { margin: 0 0 10px; color: #fca5a5; font-size: 13px; }
.auth-submit {
  width: 100%;
  height: 48px;
  padding: 0;
  border-radius: 12px;
  background: var(--pink);
  color: #2a0118;
  font-weight: 700;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.auth-submit:disabled { opacity: 0.6; }
.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--dim);
  font-size: 13px;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: #ffffff22; }
.auth-social { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-social .google { grid-column: 1 / -1; background: #fff; color: #111; }
.social.discord { background: #5865f2; color: #fff; }
.social.x { background: #fff; color: #111; }
.auth-legal { margin: 14px 0 0; color: var(--dim); font-size: 13px; line-height: 1.5; }
.auth-foot {
  margin: 16px -22px -18px;
  padding: 16px 22px;
  border-top: 1px solid #ffffff14;
  text-align: center;
  color: var(--text);
}
.auth-foot button { color: var(--pink); font-weight: 700; }
.auth-who { margin: 0 0 18px; color: var(--muted); word-break: break-all; }

/* ---------------- plans ---------------- */
.plans { padding: 12px 0 48px; }
.plans h2 {
  margin: 8px 16px 14px;
  text-align: center;
  font-size: 28px;
  letter-spacing: -0.5px;
}
.plan-trust {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 8px;
  color: var(--muted);
  text-align: center;
}
.plan-trust b { display: block; color: var(--gold); letter-spacing: 1px; }
.plan-trust span { display: block; margin-top: 2px; font-size: 12px; color: var(--dim); }
.plan-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 12px 16px 8px;
  scrollbar-width: none;
}
.plan-row::-webkit-scrollbar { display: none; }
.plan-card {
  flex: 0 0 min(280px, 78%);
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 16px;
  border-radius: 18px;
  background: #161618;
  border: 1px solid #ffffff18;
}
.plan-card.best {
  border-color: #f9718788;
  background: linear-gradient(180deg, #1c1c20 55%, #3a2030);
  box-shadow: 0 18px 40px #f971872e;
}
.plan-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.plan-card header b { display: block; font-size: 18px; }
.plan-card header em { display: block; margin-top: 4px; font-style: normal; font-size: 12px; font-weight: 700; color: var(--pink); }
.off {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f0b429;
  color: #2a1d00;
  font-size: 12px;
  font-weight: 700;
}
.price { margin: 22px 0 0; }
.price strong { font-size: 36px; letter-spacing: -1px; }
.price span { color: var(--muted); }
.was { margin: 4px 0 16px; color: var(--dim); text-decoration: line-through; }
.plan-card.best .was { text-decoration: line-through; }
.plan-go {
  margin-top: auto;
  height: 46px;
  border-radius: 12px;
  background: #2a2a2e;
  color: #fff;
  font-weight: 700;
}
.plan-go.on { background: var(--pink); color: #2a0118; }
.plan-dots { display: flex; justify-content: center; gap: 6px; margin: 8px 0 18px; }
.plan-dots i { width: 6px; height: 6px; border-radius: 50%; background: #ffffff33; }
.plan-dots i.on { background: #fff; }
.plan-benefits {
  margin: 8px 16px 0;
  padding: 16px;
  border-radius: 16px;
  background: #141416;
  border: 1px solid #ffffff12;
}
.plan-benefits h3 { margin: 0 0 12px; font-size: 16px; color: var(--muted); }
.plan-benefits ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.plan-benefits li { padding-left: 22px; position: relative; }
.plan-benefits li::before { content: "✦"; position: absolute; left: 0; color: var(--pink); }

.pay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: #000000a6;
}
.pay-card {
  position: relative;
  width: min(440px, 100%);
  margin-bottom: 8px;
  padding: 22px 18px 16px;
  border-radius: 18px;
  background: #161618;
  border: 1px solid #ffffff14;
}
.pay-card h2 { margin: 0 0 8px; font-size: 22px; }
.pay-summary { margin: 0 0 14px; color: var(--muted); }
.pay-methods { display: grid; gap: 8px; margin-bottom: 12px; }
.pay-methods button {
  height: 46px;
  border-radius: 12px;
  background: #fff;
  color: #111;
  font-weight: 700;
}
.pay-methods button.on { outline: 2px solid var(--pink); }
.pay-bill { margin: 0 0 14px; color: var(--dim); font-size: 13px; line-height: 1.45; }
.pay-note { margin: 10px 0 0; color: var(--dim); font-size: 12px; text-align: center; }
