/* ═══════════════════════════════════════════════
   PAGES.CSS — per-page layout
═══════════════════════════════════════════════ */

/* ─── LANDING ─────────────────────────────────── */
#page-landing { justify-content: space-between; }

.land-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
  flex-shrink: 0;
}

.land-mid {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 22px;
}

.land-title {
  font-size: clamp(28px, 8vw, 38px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}

.land-sub {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.55;
  max-width: 320px;
}

.land-bottom {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}

/* ─── FEED ────────────────────────────────────── */
.feed-tabs {
  display: flex;
  gap: 6px;
  padding: 9px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.feed-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 16px;
  border: 1px solid var(--border-md);
  background: transparent;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inv);
  font-weight: 600;
}

.genre-block {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.genre-block:last-child { border-bottom: none; }
.cards-row-wrap { padding: 0 14px; }

/* ─── GENRE LIST ──────────────────────────────── */
.genre-page-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.genre-page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.genre-page-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}
.char-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 14px 4px;
}
@media (min-width: 420px) {
  .char-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ─── CHAT ────────────────────────────────────── */
.chat-header {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px 0 6px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-char-info { flex: 1; min-width: 0; }
.chat-char-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-char-genre {
  font-size: 11px;
  color: var(--text-3);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 12px;
}
.msg { display: flex; gap: 7px; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; max-width: 80%; }
.msg-ai   { align-self: flex-start; max-width: 86%; }

.msg-bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.msg-user .msg-bubble {
  background: var(--accent);
  color: var(--text-inv);
  border-radius: 14px 14px 3px 14px;
}
.msg-ai .msg-bubble {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 3px;
}
.msg-system {
  align-self: center;
  font-size: 11px;
  color: var(--text-4);
  padding: 2px 0;
}

/* Typing dots */
.typing { display: flex; gap: 4px; padding: 3px 1px; }
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: blink 1.1s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.16s; }
.dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes blink { 0%,80%,100% { opacity: 0.25; } 40% { opacity: 1; } }

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 9px 11px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  background: var(--bot-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  border-radius: 13px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  padding: 9px 12px;
  resize: none;
  outline: none;
  max-height: 96px;
  overflow-y: auto;
}
.chat-textarea::placeholder { color: var(--text-4); }
.chat-textarea:focus { border-color: var(--border-hi); }

.chat-send {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-send:active { opacity: 0.8; }
.chat-send:disabled { opacity: 0.35; }
.chat-send svg path { stroke: var(--text-inv); }

/* ─── PROFILE ─────────────────────────────────── */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.profile-name { font-size: 16px; font-weight: 600; }
.profile-email { font-size: 13px; color: var(--text-3); margin-top: 1px; }

.profile-section { padding: 0 16px 14px; }
.profile-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 18px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── CHATS (мессенджер) ──────────────────────── */
.chats-list { display: flex; flex-direction: column; }

.chat-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.chat-row:active { background: var(--bg-hi); }

.chat-row-info { flex: 1; min-width: 0; }
.chat-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.chat-row-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.chat-row-time {
  font-size: 11px;
  color: var(--text-4);
  flex-shrink: 0;
}
.chat-row-preview {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-row-nsfw {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-hi);
  color: var(--text-3);
  margin-left: 6px;
  letter-spacing: 0.04em;
}

/* ─── Conversation list for a single character ─── */
.conv-list { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.conv-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 12px;
  cursor: pointer;
}
.conv-item:active { background: var(--bg-hi); }
.conv-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.conv-item-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item-time { font-size: 11px; color: var(--text-4); flex-shrink: 0; }
.conv-item-preview {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item-meta {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 4px;
}

/* ─── Sticky feed tabs on genre page ─────────── */
#page-genre .feed-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
}

/* ─── Message: action + thought formatting ───── */
.msg-action {
  font-style: italic;
  color: var(--text-2);
  opacity: 0.85;
}
.msg-thought {
  display: inline-block;
  font-style: italic;
  color: var(--text-3);
  background: var(--bg-input);
  border-left: 2px solid var(--border-hi);
  padding: 1px 7px;
  border-radius: 0 5px 5px 0;
  margin: 2px 0;
}

/* ─── Tool call indicator ───────────────────── */
.tool-indicator {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-4);
  padding: 4px 9px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 11px;
  margin: 2px 0;
}
.tool-indicator svg { opacity: 0.6; }

/* ─── Character info panel (in chat) ─────────── */
.char-info-modal { max-height: 88vh; }
.char-info-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 4px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.char-info-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.char-info-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.char-info-section { margin-bottom: 14px; }
.char-info-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}
.char-info-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ─── 18+ section in character form ──────────── */
.nsfw-section {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nsfw-section.hidden { display: none; }
.nsfw-warn {
  font-size: 12px;
  color: var(--text-3);
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  line-height: 1.5;
}

/* ─── Age gate modal ──────────────────────────── */
.age-gate {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 6px;
}
.age-gate-icon {
  width: 48px;
  height: 48px;
  border: 1.5px solid var(--border-hi);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  margin-bottom: 4px;
  font-size: 17px;
  font-weight: 700;
}