/* Base */
@charset "UTF-8";
:root {
  --bg: #000000;
  --card: #161629;
  --text: #e6e6ea;
  --muted: #b3b3b8;
  --accent: #453589;
  --accent-2: #2dd4bf;
  --error: #ef4444;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
    Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
/* Honor the HTML `hidden` attribute for any element */
[hidden] { display: none !important; }
.header {
  padding: 16px;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brand-div { width: 100%; }
.header .brand {
  display: block;
  /*width: 100%;*/
  max-height: 45px;
  object-fit: contain;
}
.title-div { text-align: center; }
.sorting-wrap {
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.sorting-dropdown {
  flex: 1;
  min-width: 0;
  position: relative;
}
.sorting-trigger {
  width: 100%;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  padding: 10px 12px;
  min-height: 42px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.sorting-trigger:hover {
  background-color: #1d1d33;
  border-color: rgba(124,92,255,0.55);
}
.sorting-trigger:focus {
  outline: none;
  border-color: rgba(124,92,255,0.8);
  box-shadow: 0 0 0 3px rgba(124,92,255,0.2);
}
.sorting-arrow {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-right: 2px solid #e6e6ea;
  border-bottom: 2px solid #e6e6ea;
  transform: rotate(45deg) translateY(-2px);
  opacity: 0.95;
  margin-right: 2px;
  flex: 0 0 auto;
}
.sorting-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #161629;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 2px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}
.sorting-option {
    width: 100%;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 9px 12px;
    min-height: 28px;
    line-height: 1.35;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14.5px;
}
.sorting-option:hover {
  background-color: #252542;
}
.sorting-option.is-active {
  background-color: rgba(124,92,255,0.2);
}
.sorting-select-native { display: none; }
.random-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 10px 12px;
  min-height: 42px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.random-btn:active { transform: translateY(1px); }

@media (max-width: 360px) {
  .sorting-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .sorting-dropdown,
  .random-btn {
    width: 100%;
  }
}
.stats { display:inline-block; margin: 6px auto; color:#fff; border-radius:999px; font-size:13px; padding:6px 12px; }
    .stats.characters {
        background: var(--card);
    }
    .stats.chats {
            margin-left: 10px;
        background: var(--card);
    }
.stats-row { display:block; gap:20px; justify-content:flex-start; padding: 0 16px; }
.header h1 {
  font-size: 18px;
  margin: 0;
}
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 12px;
}
@media (min-width: 560px) {
  .cards-grid { gap: 16px; padding: 16px; }
}
.card {
  position: relative;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}
.card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  background: #0f0f14;
  object-fit: cover;
}
.card .body {
  padding: 10px 12px 2px 12px;
}
.card .title {
  font-size: 14px;
  font-weight: 600;
  margin: 6px 0 4px 0;
}
.card .desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.25;
    min-height: 2.6em;
}
.card .footer {
  padding: 12px;
}
.btn {
  width: 100%;
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 0;
}

.btn-60 {
    margin-bottom: 60px;
}

.btn:active {
    transform: translateY(1px);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
    padding: 0 12px 12px;
    margin-bottom: 0;
    padding-right: 0px;
}

.toolbar60 {
    /*margin-bottom: 60px;*/
}
.scroll-top {
    appearance: none;
    border: 0;
    border-radius: 999px;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 18px;
}
.scroll-top:active { transform: translateY(1px); }

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
}

.favorite-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.75);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.2s ease, color 0.2s ease;
  z-index: 2;
}

.favorite-btn.is-active {
  background: rgba(255, 196, 0, 0.2);
  color: #ffd84d;
}

.favorite-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.favorite-btn:active {
  transform: scale(0.95);
}
.badge .icon {
  width: 14px; height: 14px;
  display: inline-block;
 /* background: var(--accent-2);
  mask: url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22><path fill=%22%23000%22 d=%22M12 21q-.425 0-.713-.288T11 20v-5.1L5.5 8.8q-.3-.275-.413-.65T4.975 7.5q0-.425.175-.8t.5-.625l1.2-.975q.3-.25.613-.363T8.1 4.625q.375 0 .738.138t.637.387l.85.85q.35.35.525.8t.175.925V8q0 .275.2.475t.475.2q.25 0 .45-.175t.25-.45l.4-1.6q.175-.7.713-1.138T13.8 5.9q.4 0 .775.138t.65.412l1.15 1.2q.275.275.412.625t.138.75q0 .45-.175.825t-.525.675L13 12.9V20q0 .425-.288.713T12 21Z"/></svg>') center / contain no-repeat;*/
}

.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
  color: var(--muted);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.error { color: var(--error); text-align:center; padding: 12px; }

/* Chats list */
.list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 80px;
}
.row { display: flex; gap: 10px; background: var(--card); border-radius: 12px; padding: 10px; }
.row .logo { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background:#0f0f14; }
.row .logo.sm { width: 28px; height: 28px; }
/* Topbar small logo */
.logo.sm { width: 50px; height: 50px; }
.row .col { flex: 1; }
.row-title { font-size: 14px; font-weight: 600; }
.row-sub { font-size: 12px; color: var(--muted); }
.row-desc { font-size: 13px; color: var(--muted); margin-top: 6px; }

.topbar { display: flex; align-items: center; gap: 8px; padding: 12px; }
.btn-back { appearance:none; border:0; background:transparent; color:var(--text); font-size:18px; }
.top-title { font-weight:600; }

.chat { display:flex; flex-direction:column; gap:8px; padding: 12px; }
.bubble { padding: 10px 12px; border-radius: 12px; }
    .bubble.user {
        background: #2f2e57;
        align-self: end;
        margin-left: 30px;
    }
    .bubble.ai {
        background: #180f21;
        align-self: flex-end;
        margin-right: 30px;
    }
.bubble .meta { font-size: 11px; color: var(--muted); margin-bottom: 6px; }

/* Floating menu */
.floating-menu {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 14px;
    display: flex;
    gap: 46px;
    padding: 10px 16px;
    padding: 8px 16px;
    padding-left: 25px;
    padding-right: 25px;
    background: rgba(22,22,41,0.75);
    backdrop-filter: blur(8px);
    border-radius: 999px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}
.fm-link {
  color: var(--text);
  text-decoration: none;
  font-size: 22px;
}
.fm-link:active { transform: translateY(1px); }

/* Settings sheet */
.settings-menu {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: grid;
  place-items: end center;
}
.settings-menu .sheet {
  width: 100%; max-width: 560px;
  background: var(--card);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 16px;
}
.sheet-close { appearance:none; border:0; background:transparent; color:var(--text); font-size: 20px; }
.sheet-link { display:block; color: var(--text); text-decoration:none; padding: 12px 0; }
.sheet-link + .sheet-link { border-top: 1px solid rgba(255,255,255,0.1); }