/* ============================================================
   AI Companion Studio — dark luxury theme
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #0a0910;
  --bg-raised: #121019;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3eef5;
  --text-dim: #a89fb3;
  --text-faint: #6f6680;
  --rose: #fb4d6d;
  --rose-soft: #ff7d92;
  --gold: #d8b08c;
  --accent-grad: linear-gradient(135deg, #fb4d6d 0%, #d4496e 55%, #b03a8c 100%);
  --glow: 0 0 40px rgba(251, 77, 109, 0.25);
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(176, 58, 140, 0.18), transparent 60%),
    radial-gradient(800px 500px at -10% 20%, rgba(251, 77, 109, 0.12), transparent 60%),
    radial-gradient(700px 600px at 50% 110%, rgba(216, 176, 140, 0.07), transparent 60%);
}

.hidden { display: none !important; }
.small { font-size: 12.5px; color: var(--text-dim); }

/* ---------- shell ---------- */

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell.browse-mode .chat-view { display: none; }
.app-shell.chat-mode .browse-view { display: none; }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent-grad);
  box-shadow: var(--glow);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.92);
  clip-path: path("M6 11 C 2 8, 0 5.5, 0 3.5 C 0 1.5, 1.6 0, 3.3 0 C 4.4 0, 5.5 0.7, 6 1.7 C 6.5 0.7, 7.6 0, 8.7 0 C 10.4 0, 12 1.5, 12 3.5 C 12 5.5, 10 8, 6 11 Z");
}

.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.brand-name em {
  font-style: italic;
  color: var(--gold);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

/* age pill */

.age-check { cursor: pointer; user-select: none; }
.age-check input { position: absolute; opacity: 0; pointer-events: none; }

.age-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
}

.age-check input:checked + .age-pill {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow);
}

.age-check input:focus-visible + .age-pill {
  outline: 2px solid var(--rose-soft);
  outline-offset: 2px;
}

/* ---------- buttons ---------- */

.btn-primary {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent-grad);
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: var(--glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn-primary.wide { width: 100%; padding: 12px 22px; }

.btn-ghost {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-ghost:hover { background: var(--surface-strong); border-color: var(--border-strong); }
.btn-ghost:disabled { opacity: 0.5; cursor: default; }

.btn-danger {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: rgba(220, 38, 38, 0.18);
  border: 1px solid rgba(220, 38, 38, 0.45);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-danger:hover { background: rgba(220, 38, 38, 0.32); border-color: rgba(220, 38, 38, 0.65); }
.btn-danger:disabled { opacity: 0.5; cursor: default; }
.btn-danger.wide { width: 100%; }

/* ---------- account chip + popover ---------- */

.account-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 16px 5px 6px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.account-chip:hover { border-color: var(--border-strong); background: var(--surface-strong); }

.account-initial {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.account-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 230px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  z-index: 50;
}

.account-popover strong { font-size: 14.5px; }
.account-email { font-size: 12.5px; color: var(--text-dim); word-break: break-all; }

.account-id-row {
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.account-diamond-row {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #8fd3ff;
  background: rgba(94, 178, 255, 0.1);
  border: 1px solid rgba(94, 178, 255, 0.25);
  border-radius: 999px;
  padding: 5px 12px;
  margin: 2px 0 4px;
}

.account-id-row code {
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--gold);
}

/* ---------- browse view ---------- */

.browse-hero { padding: 26px 0 6px; }

.browse-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.5vw, 44px);
  font-weight: 500;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.browse-hero p { margin: 0; color: var(--text-dim); font-size: 15px; }

.character-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 22px 0 26px;
}

.filter-chip {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.filter-chip:hover { color: var(--text); border-color: var(--border-strong); }

.filter-chip.active {
  color: #fff;
  background: var(--accent-grad);
  border-color: transparent;
  box-shadow: var(--glow);
}

.character-roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}

/* ---------- character cards ---------- */

.character-card {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  transform: translateY(0);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.character-card:hover,
.character-card:focus-visible {
  transform: translateY(-5px);
  border-color: rgba(251, 77, 109, 0.5);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.55), var(--glow);
  outline: none;
}

.character-card.active { border-color: var(--rose); }

.card-portrait {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 64px;
  color: var(--text-faint);
  background: linear-gradient(160deg, #221c2e, #14101d);
}

.card-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
  transition: transform 0.45s ease;
}

.character-card:hover .card-portrait img { transform: scale(1.05); }

.card-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 9, 16, 0) 38%, rgba(10, 9, 16, 0.45) 62%, rgba(10, 9, 16, 0.92) 100%);
  pointer-events: none;
}

.card-header {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: flex-end;
}

.card-archetype {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffe9ee;
  background: rgba(10, 9, 16, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 5px 11px;
}

.card-details {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 16px 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.card-topline {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.card-topline strong {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: #fff;
}

.card-topline small { font-size: 14px; color: var(--gold); font-weight: 600; }

.card-tagline {
  font-size: 12.5px;
  color: rgba(243, 238, 245, 0.82);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags { display: flex; gap: 6px; }

.card-tags span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 3px 9px;
}

/* ---------- chat view ---------- */

.chat-view {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
  flex: 1;
  min-height: 0;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: calc(100vh - 110px);
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.panel h2 {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* profile card */

.profile-panel {
  padding: 0;
  overflow: hidden;
  position: relative;
  aspect-ratio: 4 / 5;
  flex-shrink: 0;
}

.profile-portrait {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 64px;
  color: var(--text-faint);
  background: linear-gradient(160deg, #221c2e, #14101d);
}

.profile-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
}

.profile-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 40px 18px 16px;
  background: linear-gradient(180deg, rgba(10, 9, 16, 0) 0%, rgba(10, 9, 16, 0.78) 55%, rgba(10, 9, 16, 0.95) 100%);
}

.profile-overlay strong {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
}

.profile-overlay p { margin: 2px 0 10px; font-size: 13px; color: var(--text-dim); }

.character-meta { display: flex; flex-wrap: wrap; gap: 6px; }

.character-meta span {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  background: rgba(216, 176, 140, 0.12);
  border: 1px solid rgba(216, 176, 140, 0.25);
  border-radius: 999px;
  padding: 3px 10px;
}

/* status grid */

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.status-grid > div { display: flex; flex-direction: column; gap: 3px; }

.status-grid span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.status-grid strong { font-size: 12px; letter-spacing: 0.02em; color: var(--rose-soft); overflow-wrap: anywhere; }

#memoryList {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#memoryList li {
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
}

#proactiveText { margin: 10px 0 0; }

.sidebar-danger-panel {
  border-color: rgba(220, 38, 38, 0.2);
  background: rgba(220, 38, 38, 0.04);
  margin-top: auto; /* push to bottom of sidebar */
}

/* chat column */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 110px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 9, 16, 0.35);
}

.back-button {
  padding: 7px 9px;
  display: inline-flex;
  align-items: center;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(251, 77, 109, 0.55);
  background: linear-gradient(160deg, #221c2e, #14101d);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  color: var(--text-faint);
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
}

.chat-header-text { display: flex; flex-direction: column; }
.chat-header-text strong { font-family: var(--font-display); font-size: 17px; font-weight: 500; }
.chat-header-text span { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }

.chat-header-wallet {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.info-button {
  display: none; /* shown on mobile only */
  align-items: center;
  justify-content: center;
  padding: 7px 9px;
}

.info-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(5, 4, 9, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.diamond-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #8fd3ff;
  background: rgba(94, 178, 255, 0.1);
  border: 1px solid rgba(94, 178, 255, 0.3);
  border-radius: 999px;
  padding: 6px 13px;
}

.checkin-btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #0a0910;
  background: linear-gradient(135deg, #ffd98a, #d8b08c);
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(216, 176, 140, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.checkin-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.checkin-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.8);
  display: inline-block;
}

/* messages */

.messages {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.message {
  max-width: 72%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  animation: msg-in 0.25s ease both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  background: var(--accent-grad);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 22px rgba(251, 77, 109, 0.25);
}

.message.character {
  align-self: flex-start;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.message.notice {
  align-self: center;
  max-width: 84%;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  padding: 8px 18px;
}

/* action text — *italic narrative* shown styled, not as raw asterisks */

.action-text {
  font-style: italic;
  color: var(--text-dim);
  opacity: 0.82;
}

/* confirm modal */

.confirm-modal {
  max-width: 340px;
  text-align: center;
}

.confirm-modal h2 { font-size: 20px; margin: 0 0 8px; }
.confirm-modal .small { margin: 0 0 22px; }

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-actions .btn-ghost { flex: 1; }
.confirm-actions .btn-danger { flex: 1; }

/* voice replay button on character bubbles */

.message.character {
  position: relative;
  padding-right: 38px;
}

.msg-voice {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.message.character:hover .msg-voice,
.msg-voice:focus-visible { opacity: 1; }
.msg-voice:hover { color: var(--rose-soft); border-color: rgba(251, 77, 109, 0.5); }
.msg-voice:disabled { opacity: 0.4; cursor: default; }

/* typing indicator */

.message.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 14px 17px;
}

.message.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.message.typing i:nth-child(2) { animation-delay: 0.15s; }
.message.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* composer */

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: rgba(10, 9, 16, 0.35);
}

.composer input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 20px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer input::placeholder { color: var(--text-faint); }

.composer input:focus {
  border-color: rgba(251, 77, 109, 0.55);
  box-shadow: 0 0 0 3px rgba(251, 77, 109, 0.15);
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--accent-grad);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow);
  transition: transform 0.15s ease, filter 0.15s ease;
  flex-shrink: 0;
}

.send-btn:hover { transform: scale(1.06); filter: brightness(1.08); }
.send-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* mic button */

.mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.mic-btn:hover { color: var(--text); border-color: var(--border-strong); }
.mic-btn.listening {
  color: var(--rose);
  border-color: var(--rose);
  background: rgba(251, 77, 109, 0.12);
  box-shadow: 0 0 0 4px rgba(251, 77, 109, 0.15);
  animation: mic-pulse 1.2s infinite ease-in-out;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(251, 77, 109, 0.15); }
  50% { box-shadow: 0 0 0 8px rgba(251, 77, 109, 0.08); }
}

/* icon buttons in header */

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.call-button { color: #4ade80; }
.call-button:hover { color: #fff; background: rgba(74, 222, 128, 0.15); border-color: rgba(74, 222, 128, 0.4); }

.gift-button { color: var(--gold); }
.gift-button:hover { color: #fff; background: rgba(216, 176, 140, 0.15); border-color: rgba(216, 176, 140, 0.4); }

/* calling overlay */

.calling-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calling-bg {
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 9, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.calling-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(380px, 94vw);
  padding: 40px 24px 36px;
}

.calling-portrait {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(251, 77, 109, 0.6);
  box-shadow: 0 0 40px rgba(251, 77, 109, 0.3);
  background: linear-gradient(160deg, #221c2e, #14101d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 48px;
  color: var(--text-faint);
  animation: call-ring 2.5s infinite ease-in-out;
}

.calling-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
}

@keyframes call-ring {
  0%, 100% { box-shadow: 0 0 40px rgba(251, 77, 109, 0.3); }
  50% { box-shadow: 0 0 60px rgba(251, 77, 109, 0.55); }
}

.calling-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  color: #fff;
}

.calling-status {
  font-size: 13.5px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.calling-transcript {
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.call-transcript-line {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.call-transcript-line.user {
  align-self: flex-end;
  color: var(--text);
  background: rgba(251, 77, 109, 0.1);
  border-color: rgba(251, 77, 109, 0.25);
}

.calling-controls {
  margin-top: 12px;
  display: flex;
  gap: 20px;
  align-items: center;
}

.call-end-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #e53e3e;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 24px rgba(229, 62, 62, 0.45);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.call-end-btn:hover { transform: scale(1.06); filter: brightness(1.1); }

/* gift modal */

.gift-modal { max-width: 360px; }

.gift-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.gift-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
}

.gift-item:hover {
  border-color: var(--gold);
  background: rgba(216, 176, 140, 0.1);
  transform: translateY(-2px);
}

.gift-emoji { font-size: 32px; line-height: 1; }

.gift-item strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.gift-cost {
  font-size: 11.5px;
  font-weight: 700;
  color: #8fd3ff;
}

/* ---------- auth modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 4, 9, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 30px 28px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), var(--glow);
  animation: msg-in 0.25s ease both;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  margin: 0 0 4px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text); }

.auth-tabs {
  display: flex;
  gap: 4px;
  margin: 18px 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: none;
  border-radius: 999px;
  padding: 9px 0;
  cursor: pointer;
  transition: all 0.18s ease;
}

.auth-tab.active {
  color: #fff;
  background: var(--accent-grad);
  box-shadow: var(--glow);
}

.auth-form { display: flex; flex-direction: column; gap: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.field input {
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: rgba(251, 77, 109, 0.55);
  box-shadow: 0 0 0 3px rgba(251, 77, 109, 0.15);
}

.auth-error {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  color: #ff8095;
}

.auth-footnote { margin: 16px 0 0; text-align: center; color: var(--text-faint); }

/* ---------- responsive ---------- */

@media (max-width: 920px) {
  /* 16px inputs stop iOS Safari from auto-zooming on focus */
  .composer input,
  .field input { font-size: 16px; }

  /* Keyboard fix: lock body scroll but let the shell track visual viewport */
  body.chat-locked {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* Shell is position:fixed and tracks the visual viewport via JS CSS vars.
     When the keyboard opens, --app-height shrinks to the visible area height
     and --vv-top offsets the shell so it sits flush with the visible area.
     This guarantees the composer is always above the keyboard.
     CRITICAL: min-height:0 overrides the desktop min-height:100vh on .app-shell,
     which would otherwise force the shell taller than the keyboard-reduced viewport. */
  .app-shell.chat-mode {
    position: fixed;
    top: var(--vv-top, 0px);
    left: 0;
    right: 0;
    width: 100%;
    min-height: 0;
    height: var(--app-height, 100svh);
    padding-bottom: 0;
    overflow: hidden;
  }

  .app-shell.chat-mode .topbar { padding: 12px 0 10px; }

  .app-shell.chat-mode .chat-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 0;
  }

  /* Side panels live in a slide-over drawer on phones (info button) */
  .app-shell.chat-mode .chat-sidebar { display: none; }

  .app-shell.chat-mode.info-open .chat-sidebar {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 88vw);
    max-height: none;
    z-index: 90;
    margin: 0;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
    background: var(--bg-raised);
    border-left: 1px solid var(--border-strong);
    box-shadow: -24px 0 60px rgba(0, 0, 0, 0.55);
    overflow-y: auto;
    animation: drawer-in 0.22s ease both;
  }

  .info-button { display: inline-flex; }

  .app-shell.chat-mode .chat {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    margin-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .composer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

  .chat-view { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .app-shell { padding: 0 14px 32px; }
  .app-shell.chat-mode { padding: 0 10px; }
  .character-roster { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .message { max-width: 86%; }
  .brand-name { font-size: 16px; }
  .account-chip-name { display: none; }
  .chat-header { padding: 10px 12px; }
  .composer { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .messages { padding: 16px 12px; }
}
