/* ============================================================
   Hi.AI — AI Character Chat
   Light theme. Mobile-first, responsive up to desktop.
   ============================================================ */

:root {
  /* Brand */
  --brand-pink: #ff4f87;
  --brand-pink-strong: #ff2d6f;
  --brand-purple: #b15cff;
  --brand-gradient: linear-gradient(135deg, #ff5c9a 0%, #ff4f87 45%, #b15cff 100%);

  /* Surfaces */
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f1f1f4;
  --surface-3: #e9e9ee;

  /* Text */
  --text: #1c1c22;
  --text-2: #5f6068;
  --text-3: #9a9aa3;
  --on-dark: #ffffff;

  /* Lines */
  --border: #ececf1;
  --border-strong: #e0e0e6;

  /* Pills */
  --chip-bg: #ffffff;
  --chip-active-bg: #1c1c22;
  --chip-active-text: #ffffff;

  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.06);
  --shadow-md: 0 6px 20px rgba(20, 20, 30, 0.10);
  --shadow-lg: 0 12px 40px rgba(20, 20, 30, 0.16);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  --sidebar-w: 248px;
  --header-h: 64px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img { display: block; }

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d6d6dd; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #c4c4cd; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   App shell layout (desktop): sidebar + main
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  grid-template-rows: 100dvh;   /* dynamic viewport: fits iOS Safari toolbars */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------------- Sidebar (desktop) ---------------- */
.sidebar {
  grid-column: 1;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  overflow: hidden;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.5px;
  padding: 6px 8px 18px;
}
.logo-mark {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 600;
  font-size: 15px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  text-align: left;
  width: 100%;
}
.nav__item svg { width: 22px; height: 22px; flex: none; }
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active { background: var(--surface-2); color: var(--text); }
.nav__item.is-active svg { color: var(--brand-pink); }

.sidebar__section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
  padding: 18px 12px 8px;
  font-weight: 700;
}

.recent-chats {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -4px;
  padding: 0 4px;
}
.recent-chats__empty {
  color: var(--text-3);
  font-size: 13px;
  padding: 6px 12px;
}
.recent-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  width: 100%;
  text-align: left;
  transition: background 0.15s var(--ease);
}
.recent-chat:hover { background: var(--surface-2); }
.recent-chat__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; flex: none; background: var(--surface-3);
}
.recent-chat__name {
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-chat__sub {
  font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar__footer {
  padding: 14px 12px 4px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
  color: var(--text-3);
  font-size: 12px;
}
.sidebar__footer-links { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.sidebar__footer-links a:hover { color: var(--brand-pink); }

/* ---------------- Main column ---------------- */
.main {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  min-width: 0;
}

/* Top header (desktop) */
.topbar {
  height: var(--header-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__mobile-logo { display: none; }

.search {
  position: relative;
  flex: 1;
  max-width: 520px;
}
.search input {
  width: 100%;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  padding: 0 16px 0 44px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border 0.15s var(--ease), background 0.15s var(--ease);
}
.search input::placeholder { color: var(--text-3); }
.search input:focus {
  border-color: var(--brand-pink);
  background: var(--surface);
}
.search__icon {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-3); pointer-events: none;
}

.topbar__spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: transform 0.12s var(--ease), box-shadow 0.15s var(--ease),
    background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--ghost { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.btn--ghost:hover { border-color: var(--brand-pink); color: var(--brand-pink); }
.btn--primary { background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-md); }
.btn--primary:hover { box-shadow: var(--shadow-lg); }
.btn--block { width: 100%; height: 52px; font-size: 16px; }
.btn svg { width: 18px; height: 18px; }

/* View container fills the main area below the header */
.view-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Scrollable content region (browse / detail) */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 40px;
}

/* ---------------- Category chips ---------------- */
.chips {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
}
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.is-active {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
  border-color: var(--chip-active-bg);
}

/* ---------------- Card grid ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--surface-3);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: var(--surface-3);
}
.card__overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.32) 40%, rgba(0,0,0,0) 68%);
}
.card__badge {
  position: absolute; top: 10px; right: 10px;
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
}
.card__badge svg { width: 13px; height: 13px; }
.card__body {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px 13px 14px;
  color: #fff;
}
.card__name {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card__desc {
  font-size: 12.5px;
  opacity: 0.92;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------- Section headers ---------------- */
.section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 14px;
}
.section-head h1, .section-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.section-head .count { color: var(--text-3); font-size: 14px; font-weight: 600; }

/* ---------------- Loading / states ---------------- */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 80px 20px; color: var(--text-3); text-align: center;
}
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--brand-pink);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 16px; }
.skeleton-card {
  aspect-ratio: 3/4; border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   Character Detail view
   ============================================================ */
.detail {
  max-width: 980px;
  margin: 0 auto;
}
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-2); font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 999px; margin-bottom: 16px;
  transition: background 0.15s var(--ease);
}
.back-btn:hover { background: var(--surface-2); color: var(--text); }
.back-btn svg { width: 18px; height: 18px; }

.detail__hero {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 28px;
  align-items: start;
}
.detail__poster {
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 3/4;
  background: var(--surface-3);
  box-shadow: var(--shadow-md);
  position: relative;
}
.detail__poster img { width: 100%; height: 100%; object-fit: cover; }

.detail__info { padding-top: 4px; }
.detail__name { font-size: 30px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.5px; }
.detail__scene { font-size: 16px; color: var(--text-2); margin: 0 0 16px; }

.detail__stats { display: flex; gap: 22px; margin-bottom: 18px; }
.stat { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-weight: 600; font-size: 14px; }
.stat svg { width: 18px; height: 18px; color: var(--brand-pink); }

.detail__tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
}

.detail__section { margin-bottom: 22px; }
.detail__section h3 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.detail__section p { margin: 0; color: var(--text-2); white-space: pre-wrap; line-height: 1.6; }

/* Always-visible Start Chat bar (fixed footer of the view area) */
.detail__cta-bar {
  flex: none;
  padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(20, 20, 30, 0.05);
}
.detail__cta-bar .btn { max-width: 360px; margin: 0 auto; }

/* ============================================================
   Chat screen
   ============================================================ */
.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat__header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.chat__back {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.chat__back:hover { background: var(--surface-2); color: var(--text); }
.chat__back svg { width: 20px; height: 20px; }
.chat__avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.chat__title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.chat__subtitle { font-size: 12.5px; color: var(--text-3); }

.chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(177,92,255,0.06), transparent),
    radial-gradient(1000px 500px at -10% 110%, rgba(255,79,135,0.06), transparent);
}
.bubble {
  max-width: min(78%, 560px);
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
}
.bubble--ai {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border-bottom-left-radius: 6px;
}
.bubble--user {
  align-self: flex-end;
  background: var(--brand-gradient);
  color: #fff;
  border-bottom-right-radius: 6px;
}
/* Spoken dialogue (default bubble text) is slightly bold;
   action / scene narration (*wrapped in asterisks*) is lighter. */
.bubble--ai, .bubble--user { font-weight: 600; }
.bubble__action { font-style: italic; font-weight: 400; opacity: 0.55; }

.chat__composer {
  flex: none;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat__composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 22px;
  padding: 11px 16px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  max-height: 120px;
  line-height: 1.4;
}
.chat__composer textarea:focus { border-color: var(--brand-pink); background: var(--surface); }
.chat__send {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: var(--brand-gradient); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  transition: transform 0.12s var(--ease);
}
.chat__send:active { transform: scale(0.94); }
.chat__send svg { width: 20px; height: 20px; }
/* Typing indicator */
.bubble--typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; }
.bubble--typing .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
  animation: typing 1.2s infinite ease-in-out;
}
.bubble--typing .dot:nth-child(2) { animation-delay: 0.15s; }
.bubble--typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat__error {
  align-self: center;
  text-align: center;
  max-width: 460px;
  background: #fff0f3;
  border: 1px solid #ffd0dc;
  color: #c2255c;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 12px;
}

/* ============================================================
   Language picker
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade 0.15s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.lang-menu {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.lang-menu__title {
  font-size: 17px; font-weight: 800;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.lang-menu__list {
  overflow-y: auto;
  padding: 8px;
}
.lang-option {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  color: var(--text);
  transition: background 0.12s var(--ease);
}
.lang-option:hover { background: var(--surface-2); }
.lang-option.is-active { color: var(--brand-pink); }
.lang-option__check svg { width: 18px; height: 18px; }

/* ============================================================
   Coin badge (header) + recharge modal + toast
   ============================================================ */
.coin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff4d6 0%, #ffe5a8 100%);
  color: #8a5a00;
  border: 1px solid #f3d089;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  transition: transform .12s var(--ease), box-shadow .15s var(--ease);
}
.coin-badge:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.coin-badge:active { transform: translateY(0); }
.coin-badge svg { width: 16px; height: 16px; }
.coin-balance { min-width: 14px; text-align: center; }

.recharge {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;
  padding: 22px;
}
.recharge__title { font-size: 20px; font-weight: 800; margin: 0 0 14px; }
.recharge__pack {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  text-align: center;
  margin-bottom: 16px;
}
.recharge__pack-amount {
  font-size: 26px;
  font-weight: 800;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.recharge__pack-sub { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.recharge__paypal { min-height: 50px; margin-bottom: 12px; }
.recharge__note {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  margin-bottom: 12px;
}
.recharge__missing {
  font-size: 13px;
  color: var(--text-2);
  background: #fff6e6;
  border: 1px dashed #f3c982;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  line-height: 1.4;
}
.recharge__loading {
  font-size: 13px;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}
.recharge__missing code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 20px);
  background: #1c1c22;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  z-index: 200;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }


/* ============================================================
   Mobile header + drawer (hidden on desktop)
   ============================================================ */
.mobile-header { display: none; }
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
  opacity: 0; transition: opacity 0.2s var(--ease);
}
.drawer-backdrop.is-open { opacity: 1; }

/* ============================================================
   Floating "Download App" (mobile)
   ============================================================ */
.fab-download { display: none; }

/* ============================================================
   Responsive: tablet
   ============================================================ */
@media (max-width: 1100px) {
  .detail__hero { grid-template-columns: 260px 1fr; gap: 22px; }
}

/* ============================================================
   Responsive: mobile (<= 820px)
   ============================================================ */
@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    max-width: 84vw;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.26s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }

  .main { grid-column: 1; }

  /* Desktop topbar hidden, mobile header shown */
  .topbar { display: none; }
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    flex: none;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .mobile-header .icon-btn {
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--brand-pink);
  }
  .mobile-header .icon-btn:hover { background: var(--surface-2); }
  .mobile-header .icon-btn svg { width: 24px; height: 24px; }
  .mobile-header__logo {
    font-weight: 800; font-size: 20px; letter-spacing: -0.5px;
    flex: 1; text-align: center;
  }
  .mobile-header__actions { display: flex; align-items: center; gap: 4px; }

  .content {
    padding-top: 14px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  /* Search shown inside content area on mobile */
  .mobile-search { display: block; margin-bottom: 14px; }
  .mobile-search .search { max-width: none; }

  .grid { grid-template-columns: repeat(2, 1fr); gap: 11px; }
  .card__name { font-size: 14px; }
  .card__desc { font-size: 11.5px; }

  .section-head h1, .section-head h2 { font-size: 19px; }

  /* Detail: stack */
  .detail__hero { grid-template-columns: 1fr; gap: 18px; }
  .detail__poster { max-width: 260px; margin: 0 auto; }
  .detail__name { font-size: 24px; }
  .detail__cta { max-width: none; }

  /* Floating download button */
  .fab-download {
    display: inline-flex;
    position: fixed;
    left: 50%; transform: translateX(-50%);
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 30;
    height: 50px; padding: 0 26px;
    border-radius: 999px;
    background: var(--brand-gradient);
    color: #fff; font-weight: 700; font-size: 15px;
    align-items: center; gap: 8px;
    box-shadow: var(--shadow-lg);
  }
  .fab-download svg { width: 20px; height: 20px; }

  /* Hide fab on chat + detail screens to avoid overlap */
  .view-chat .fab-download,
  .view-detail .fab-download { display: none; }

  .chat__body {
    padding-top: 16px;
    padding-bottom: 16px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .bubble { max-width: 84%; }

  /* Bottom bars clear the home indicator / Safari toolbar and the notch sides */
  .chat__composer {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .detail__cta-bar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

.mobile-search { display: none; }

@media (max-width: 380px) {
  .grid { gap: 9px; }
}
