:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: rgba(15, 18, 26, .9);
  --surface: #1a1d25;
  --surface-2: #242832;
  --line: rgba(255,255,255,.08);
  --text: #f7f8fb;
  --muted: #858a99;
  --pink: #ed3fa4;
  --purple: #713cff;
  --green: #38d991;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(113,60,255,.11), transparent 32%),
    radial-gradient(circle at 90% 85%, rgba(237,63,164,.09), transparent 34%),
    #05070b;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

.chat-shell {
  width: min(100%, 1180px);
  height: 100svh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--bg);
  border-inline: 1px solid var(--line);
  box-shadow: 0 0 80px rgba(0,0,0,.48);
}

.chat-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(8,10,15,.86);
  backdrop-filter: blur(18px);
}

.back-link {
  display: none;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #d6d8e0;
  text-decoration: none;
  font-size: 32px;
  line-height: 1;
}

.profile-photo {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
}

.profile-photo img,
.mini-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
  border-radius: 50%;
}

.profile-photo img { border: 2px solid rgba(255,255,255,.16); }

.online-dot {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 13px;
  height: 13px;
  border: 2px solid #0a0c11;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(56,217,145,.11);
}

.profile-copy { min-width: 0; }
.profile-name { display: flex; align-items: center; gap: 7px; margin: 0; font-size: inherit; font-weight: 760; letter-spacing: -.01em; }
.verified { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #319cf6; color: #fff; font-size: 11px; }
.profile-status { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: #9ca2af; font-size: 12px; }
.profile-status span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: status-pulse 2s ease-in-out infinite; }

.header-menu {
  margin-left: auto;
  padding: 12px 4px;
  border: 0;
  background: transparent;
  color: #9ba0ad;
  font-size: 17px;
  letter-spacing: 3px;
  cursor: pointer;
}

.info-dialog {
  width: min(92vw, 620px);
  max-height: min(86svh, 720px);
  padding: 28px;
  overflow: auto;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  background: #10131a;
  color: var(--text);
  box-shadow: 0 28px 100px rgba(0,0,0,.72);
}
.info-dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(8px); }
.info-dialog h2 { max-width: 500px; margin: 4px 42px 12px 0; font-size: clamp(22px, 4vw, 30px); line-height: 1.1; }
.info-dialog > p { color: #aeb3c0; line-height: 1.55; }
.info-kicker { margin: 0; color: #d66afb !important; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.info-close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-size: 25px; cursor: pointer; }
.info-dialog details { padding: 13px 0; border-top: 1px solid var(--line); }
.info-dialog details:last-of-type { border-bottom: 1px solid var(--line); }
.info-dialog summary { cursor: pointer; font-weight: 750; line-height: 1.35; }
.info-dialog details p { margin: 9px 0 0; color: #9ca2af; line-height: 1.5; }
.info-disclaimer { font-size: 12px; }
.info-link { display: inline-flex; margin-top: 4px; color: #df76ff; font-weight: 750; text-underline-offset: 3px; }

.conversation {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px clamp(14px, 3vw, 34px) 18px;
  background:
    linear-gradient(rgba(8,10,15,.88), rgba(8,10,15,.96)),
    radial-gradient(circle at 45% 18%, rgba(113,60,255,.14), transparent 34%);
  scrollbar-width: thin;
  scrollbar-color: #303540 transparent;
}

.ambient {
  position: fixed;
  width: 280px;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .12;
  pointer-events: none;
}
.ambient-one { top: 22%; left: 8%; background: var(--purple); }
.ambient-two { right: 6%; bottom: 18%; background: var(--pink); }

.conversation-start {
  display: grid;
  place-items: center;
  min-height: clamp(120px, 28vh, 260px);
  align-content: end;
  gap: 12px;
  padding-bottom: 38px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}
.conversation-start span { padding: 6px 11px; border-radius: 999px; background: rgba(255,255,255,.045); color: #aeb3c0; }
.conversation-start p { margin: 0; }

.message-stack { display: grid; gap: 8px; width: min(100%, 670px); }
.chat-row { display: flex; align-items: flex-end; gap: 8px; animation: message-in .48s cubic-bezier(.2,.8,.2,1) both; }
.chat-row.outgoing { justify-content: flex-end; }
.mini-avatar, .avatar-spacer { flex: none; width: 30px; height: 30px; }

.bubble {
  max-width: min(78%, 520px);
  padding: 10px 14px;
  border-radius: 19px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}
.incoming-bubble { border: 1px solid rgba(255,255,255,.055); border-bottom-left-radius: 6px; background: var(--surface); }
.outgoing-bubble { border-bottom-right-radius: 6px; background: linear-gradient(135deg, var(--purple), var(--pink)); }
.delayed-message { animation-delay: .45s; }

.photo-message {
  position: relative;
  width: min(230px, 62vw);
  height: 145px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px 18px 18px 6px;
  background: var(--surface);
  cursor: pointer;
}
.photo-message > img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 25%; filter: brightness(.72); transform: scale(1.02); transition: transform .3s ease, filter .3s ease; }
.photo-message:hover > img { transform: scale(1.06); filter: brightness(.82); }
.photo-overlay { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 7px; font-size: 12px; font-weight: 750; }
.photo-overlay i { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(5,7,11,.62); border: 1px solid rgba(255,255,255,.28); font-style: normal; backdrop-filter: blur(7px); }

.typing-bubble { display: inline-flex; gap: 4px; align-items: center; min-width: 58px; }
.typing-bubble i { width: 6px; height: 6px; border-radius: 50%; background: #9297a5; animation: typing 1.1s infinite ease-in-out; }
.typing-bubble i:nth-child(2) { animation-delay: .16s; }
.typing-bubble i:nth-child(3) { animation-delay: .32s; }

.reply-media {
  display: block;
  width: min(260px, 68vw);
  max-height: 360px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px 18px 18px 6px;
  background: var(--surface);
  object-fit: cover;
}
.reply-audio { width: min(320px, 74vw); }

.composer-area {
  position: relative;
  z-index: 10;
  padding: 10px 14px calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: rgba(9,11,16,.91);
  backdrop-filter: blur(18px);
}

.fanvue-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, 560px);
  margin: 0 auto 9px;
  padding: 12px 18px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  background: linear-gradient(100deg, var(--purple), var(--pink));
  box-shadow: 0 10px 28px rgba(172,53,224,.18);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  transition: transform .2s ease, filter .2s ease;
}
.fanvue-cta:hover { transform: translateY(-2px); filter: brightness(1.08); }
.fanvue-cta strong { font-size: 19px; }

.composer { display: flex; align-items: center; gap: 8px; width: min(100%, 760px); margin: 0 auto; }
.composer-icon, .send-button { flex: none; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border-radius: 50%; }
.composer-icon { border: 1px solid var(--line); background: var(--surface); opacity: .72; }
.composer-icon svg, .send-button svg { width: 21px; height: 21px; fill: currentColor; }
.message-input-wrap { flex: 1; min-width: 0; }
.message-input-wrap input { width: 100%; height: 44px; padding: 0 17px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; outline: none; background: var(--surface); color: var(--text); }
.message-input-wrap input::placeholder { color: #747a88; }
.message-input-wrap input:focus { border-color: rgba(237,63,164,.62); box-shadow: 0 0 0 3px rgba(237,63,164,.08); }
.send-button { border: 0; background: linear-gradient(135deg, var(--purple), var(--pink)); cursor: pointer; transition: transform .18s ease, opacity .18s ease; }
.send-button:disabled { opacity: .32; cursor: default; }
.send-button:not(:disabled):active { transform: scale(.94); }

.preview-note { margin: 7px 0 0; color: #5f6470; font-size: 9px; letter-spacing: .08em; text-align: center; text-transform: uppercase; }

.photo-dialog { width: min(92vw, 520px); max-height: 90svh; padding: 0; overflow: hidden; border: 1px solid rgba(255,255,255,.14); border-radius: 24px; background: #0b0d12; box-shadow: 0 26px 90px rgba(0,0,0,.72); }
.photo-dialog::backdrop { background: rgba(0,0,0,.82); backdrop-filter: blur(8px); }
.photo-dialog img { display: block; width: 100%; max-height: 88svh; object-fit: cover; }
.photo-dialog button { position: absolute; top: 10px; right: 10px; z-index: 2; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; background: rgba(8,10,15,.65); font-size: 25px; cursor: pointer; backdrop-filter: blur(8px); }

@keyframes message-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes status-pulse { 50% { opacity: .5; box-shadow: 0 0 0 5px rgba(56,217,145,.08); } }
@keyframes typing { 0%, 80%, 100% { opacity: .32; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 700px) {
  .chat-shell { border: 0; }
  .chat-header { min-height: 72px; padding-inline: 10px 14px; }
  .back-link { display: grid; }
  .profile-photo { width: 43px; height: 43px; }
  .conversation { padding-inline: 10px; }
  .conversation-start { min-height: 23vh; padding-bottom: 28px; }
  .composer-area { padding-inline: 9px; }
  .preview-note { letter-spacing: .045em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
