/* AuroraChat — ultra-modern, fluid auth UI */
/* Base tokens */
:root {
  --bg: #0b0f16;
  --bg-2: #0e1220;
  --surface: rgba(255,255,255,0.06);
  --surface-2: rgba(255,255,255,0.08);
  --stroke: rgba(255,255,255,0.16);
  --text: #e8f0ff;
  --muted: #9fb2c8;
  --brand-1: #7cf6ff;
  --brand-2: #8a7cff;
  --brand-3: #ff6ad5;
  --ok: #80ffd9;
  --warn: #ffd479;
  --danger: #ff6a6a;
  --shadow: 0 10px 30px rgba(0,0,0,0.4), 0 6px 16px rgba(0,0,0,0.3);
  --radius: 16px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --people-strip-h: 96px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f9ff;
    --bg-2: #eef3ff;
    --surface: rgba(10, 14, 30, 0.06);
    --surface-2: rgba(10, 14, 30, 0.08);
    --stroke: rgba(10,14,30,0.12);
    --text: #0e1220;
    --muted: #425066;
    --shadow: 0 10px 30px rgba(10,14,30,0.12), 0 6px 16px rgba(10,14,30,0.08);
  }
}

/* Explicit theme toggle support */
:root.theme-light {
  --bg: #f7f9ff;
  --bg-2: #eef3ff;
  --surface: rgba(10, 14, 30, 0.06);
  --surface-2: rgba(10, 14, 30, 0.08);
  --stroke: rgba(10,14,30,0.12);
  --text: #0e1220;
  --muted: #425066;
  --shadow: 0 10px 30px rgba(10,14,30,0.12), 0 6px 16px rgba(10,14,30,0.08);
}

/* Reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 500 15px/1.5 ui-sans-serif, system-ui, Segoe UI, Roboto, Helvetica, Arial, Apple Color Emoji, Segoe UI Emoji;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% -10%, #0b1e3a, transparent 60%),
              radial-gradient(1000px 700px at 110% 10%, #2b0f2a, transparent 55%),
              linear-gradient(180deg, var(--bg), var(--bg-2));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Animated aurora background */
.scene::before,
.scene::after {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 120vh;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(124,246,255,.25), transparent 60%),
              radial-gradient(closest-side, rgba(138,124,255,.18), transparent 60%),
              radial-gradient(closest-side, rgba(255,106,213,.15), transparent 60%);
  filter: blur(40px) saturate(120%);
  transform: translate3d(0,0,0);
  animation: drift 28s var(--ease) infinite alternate;
}
.scene::after {
  inset: auto -10% -30% -10%;
  background: radial-gradient(closest-side, rgba(128,255,217,.22), transparent 60%),
              radial-gradient(closest-side, rgba(255,145,106,.12), transparent 60%),
              radial-gradient(closest-side, rgba(138,124,255,.14), transparent 60%);
  filter: blur(60px) saturate(140%);
  animation-duration: 34s;
}

@keyframes drift {
  0%   { transform: translate3d(-4%, -2%, 0) scale(1.02) rotate(0.6deg); }
  50%  { transform: translate3d(2%, 3%, 0)   scale(1.04) rotate(-0.6deg); }
  100% { transform: translate3d(5%, -1%, 0)  scale(1.03) rotate(0.4deg); }
}

/* Scene overlays */
.scene.ambient-rain::before {
  background: repeating-linear-gradient(190deg, rgba(124,246,255,.08) 0 2px, transparent 2px 6px);
  animation: rain 1.2s linear infinite;
  filter: blur(0.5px) saturate(140%);
}
@keyframes rain { to { transform: translate3d(-8%, -14%, 0) } }
.scene.neon::after {
  background: radial-gradient(closest-side, rgba(138,124,255,.25), transparent 60%), radial-gradient(closest-side, rgba(124,246,255,.18), transparent 60%);
  filter: blur(40px) saturate(160%);
}
.scene.ambient-dust::before { background: radial-gradient(closest-side, rgba(255,145,106,.10), transparent 60%); filter: blur(20px) saturate(120%); }
.scene.ambient-fireflies::after { background: radial-gradient(closest-side, rgba(255,255,180,.16), transparent 60%); filter: blur(20px) saturate(120%); animation-duration: 18s; }

/* Cyberpunk glitch vibe */
body.theme-cyberpunk .msg .bubble { position: relative; }
body.theme-cyberpunk .msg .bubble::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(90deg, rgba(124,246,255,.08), rgba(255,106,213,.08));
  mix-blend-mode: screen; animation: glitch 2.2s steps(12) infinite;
}
@keyframes glitch {
  0%, 100% { transform: translate(0,0); }
  10% { transform: translate(1px,-1px); }
  20% { transform: translate(-1px,1px); }
  30% { transform: translate(0.5px, -0.5px); }
  40% { transform: translate(-0.5px, 0.5px); }
  50% { transform: translate(0, 0); }
}

/* Layout */
.wrap {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: start;
  gap: 24px;
  padding: clamp(16px, 4vw, 32px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  user-select: none;
}
.brand.small { gap: 12px; }
.titles { display: grid; gap: 2px; }
.app-title {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: clamp(20px, 3.2vw, 28px);
}
.subtitle { margin: 0; color: var(--muted); font-weight: 500; }

.gradient-text {
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2), var(--brand-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 12px rgba(124,246,255,.15));
}

.card {
  position: relative;
  margin: 0 auto;
  width: min(480px, 92vw);
  padding: clamp(18px, 3.5vw, 28px);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(180deg, var(--surface), rgba(255,255,255,0.03));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: saturate(140%) blur(14px);
  transform-style: preserve-3d;
}

/* Animated neon border */
.card .card-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.card .card-glow::before {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  padding: 1px; /* border thickness */
  background: conic-gradient(
    from 180deg,
    rgba(124,246,255,.7), rgba(138,124,255,.7), rgba(255,106,213,.7), rgba(124,246,255,.7)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: rotate 10s linear infinite;
}

@keyframes rotate { to { transform: rotate(360deg); } }

.tilt { transition: transform .2s var(--ease); will-change: transform; }

.form { display: grid; gap: 16px; }
.form-title { margin: 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: .2px; }

.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }

.field {
  display: grid; gap: 8px; position: relative;
}
.field label {
  position: absolute; inset-inline: 14px; top: 12px;
  color: var(--muted); pointer-events: none; transition: all .2s var(--ease);
  background: transparent; padding: 0 6px; transform-origin: left top;
}
.field input {
  width: 100%;
  font: inherit; color: var(--text);
  padding: 26px 14px 12px 14px;
  border-radius: 12px; outline: none;
  background: linear-gradient(180deg, var(--surface-2), rgba(255,255,255,0.02));
  border: 1px solid var(--stroke);
  transition: border-color .2s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease);
}
.field input:focus {
  border-color: color-mix(in oklab, var(--brand-2), white 10%);
  box-shadow: 0 0 0 6px color-mix(in oklab, var(--brand-2), transparent 90%);
}
.field.filled label,
.field:focus-within label {
  top: 6px; transform: scale(.86);
  background: linear-gradient(90deg, rgba(11,15,22,.0), rgba(11,15,22,.0));
}

.field.with-icon input { padding-right: 48px; }

.with-icon .icon-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
}
.icon-btn {
  display: grid; place-items: center;
  height: 36px; width: 36px; border-radius: 10px;
  color: var(--muted);
  background: transparent; border: 1px solid transparent; cursor: pointer;
  transition: all .2s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface); border-color: var(--stroke); }
.icon { display: block; }

.check { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-2); }

.btn {
  appearance: none; border: 0; outline: 0; cursor: pointer; user-select: none;
  display: inline-grid; place-items: center; grid-auto-flow: column; gap: 10px; justify-content: center;
  border-radius: 12px; padding: 12px 16px; font-weight: 700; letter-spacing: .2px;
  transition: transform .06s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand-2), var(--brand-3));
  color: #0d0f1a; text-shadow: 0 1px 0 rgba(255,255,255,.1);
  box-shadow: 0 10px 24px rgba(138,124,255,.36), 0 6px 14px rgba(255,106,213,.22);
}
.btn.primary:hover { filter: saturate(110%) brightness(1.03); }
.btn.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--stroke);
}

.btn .btn-progress {
  --size: 18px;
  display: none; width: var(--size); height: var(--size);
  border-radius: 50%; border: 2px solid rgba(255,255,255,.5);
  border-top-color: rgba(14,18,32,.6);
  animation: spin .8s linear infinite;
}
/* Busy state */
.btn[aria-busy="true"] .btn-progress { display: inline-block; }
.btn[aria-busy="true"] .btn-label { opacity: .72; }
@keyframes spin { to { transform: rotate(360deg); } }

.divider { display: grid; align-items: center; justify-items: center; grid-template-columns: 1fr auto 1fr; gap: 12px; color: var(--muted); }
.divider::before, .divider::after { content: ""; height: 1px; background: linear-gradient(90deg, transparent, var(--stroke), transparent); }

.alt-actions { display: grid; gap: 8px; }
.hint { margin: 4px 2px 0; color: var(--muted); font-size: 12px; text-align: center; }

.foot { display: flex; justify-content: center; }
.chip { background: var(--surface); color: var(--text); border: 1px solid var(--stroke); border-radius: 999px; padding: 8px 12px; cursor: pointer; }

/* Password strength meter */
.meter { position: absolute; left: 12px; right: 48px; bottom: 8px; height: 6px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.meter .bar { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, var(--danger), var(--warn), var(--ok)); transition: width .25s var(--ease); filter: saturate(140%); }

/* Links */
.link { color: color-mix(in oklab, var(--brand-1), white 10%); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* Autofill fix */
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 30px rgba(255,255,255,0.05) inset;
  -webkit-text-fill-color: var(--text);
}

/* Responsiveness */
@media (max-width: 520px) {
  .wrap { gap: 16px; }
  .card { padding: 16px; }
}

/* App bar for chat */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 12px clamp(12px, 3vw, 20px);
  backdrop-filter: saturate(140%) blur(8px);
  background: linear-gradient(180deg, rgba(0,0,0,0.28), rgba(0,0,0,0.06));
  border-bottom: 1px solid var(--stroke);
}
.appbar .title { margin: 0; text-align: center; font-weight: 800; letter-spacing: .2px; }
/* Improve readability of the chat header title by overriding gradient text */
.appbar .title.gradient-text {
  background: none;
  -webkit-background-clip: initial; background-clip: initial;
  color: var(--text);
  filter: none;
  text-shadow: 0 1px 0 rgba(0,0,0,.25), 0 0 18px color-mix(in oklab, var(--brand-1), transparent 85%);
}
.appbar .actions { display: flex; justify-content: flex-end; gap: 8px; }
.appbar .search-wrap { display: none; grid-column: 1 / -1; justify-self: center; position: relative; width: min(680px, 92vw); }
.appbar.searching .title { display: none; }
.appbar.searching .search-wrap { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.search-field { position: relative; }
.search-input {
  width: 100%; border: 1px solid var(--stroke); border-radius: 12px;
  background: linear-gradient(180deg, var(--surface-2), rgba(255,255,255,0.02));
  color: var(--text); padding: 12px 14px 12px 42px; font: inherit;
}
.search-field #search-toggle { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); height: 32px; width: 32px; border-radius: 8px; background: transparent; border: 1px solid transparent; display: grid; place-items: center; }
.search-field #search-toggle:hover { color: var(--text); background: var(--surface); border-color: var(--stroke); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: linear-gradient(180deg, var(--surface), rgba(255,255,255,0.03));
  border: 1px solid var(--stroke); border-radius: 12px; padding: 8px;
  box-shadow: var(--shadow); backdrop-filter: saturate(140%) blur(8px);
  display: none; max-height: 40vh; overflow: auto;
}
.appbar.searching .search-results { display: block; }
.appbar .actions { display: flex; justify-content: flex-end; gap: 8px; }
.appbar .spacer { height: 1px; }

/* Chat layout */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px clamp(12px, 3vw, 20px);
}

.panel {
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(180deg, var(--surface), rgba(255,255,255,0.03));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: saturate(140%) blur(12px);
}

.sidebar { display: grid; grid-template-rows: auto 1fr; }
.side-header {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px; border-bottom: 1px solid var(--stroke);
}

.chat-list { overflow: auto; padding: 8px; display: grid; gap: 6px; }
.chat-item {
  width: 100%; text-align: left; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
  color: var(--text); cursor: pointer; transition: background .2s var(--ease), border-color .2s var(--ease);
}
.chat-item:hover { border-color: color-mix(in oklab, var(--brand-1), white 10%); }
.chat-item.active { border-color: color-mix(in oklab, var(--brand-2), white 10%); background: linear-gradient(180deg, rgba(138,124,255,0.06), rgba(255,106,213,0.04)); }
.chat-item .meta { display: grid; }
.chat-item .meta small { color: var(--muted); }
.chat-item time { color: var(--muted); font-size: 12px; }
.avatar { height: 36px; width: 36px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 30% 20%, var(--brand-1), var(--brand-2)); color: #0e1220; font-weight: 900; }

.conversation { position: relative; min-height: calc(100dvh - 90px); display: grid; grid-template-rows: auto 1fr auto; min-height: 0; margin-top: 14px; transition: transform .24s var(--ease), opacity .24s var(--ease); }
.conv-empty { margin: auto; text-align: center; }
.conv-empty .muted { color: var(--muted); }

@media (max-width: 880px) {
  .chat-layout { grid-template-columns: 1fr; }
}

/* Mobile refinements */
@media (max-width: 640px) {
  :root { --people-strip-h: 78px; }
  .appbar { padding: 8px clamp(10px, 3vw, 16px); }
  .appbar .title { font-size: 18px; }
  .people-list { gap: 10px; padding: 6px 6px 8px; }
  .avatar.lg { height: 40px; width: 40px; }
  .uname { font-size: 10px; max-width: 64px; }
  .conversation { margin-top: 10px; }
  .conv-head { padding: 10px 12px 8px; padding-top: 26px; }
  .composer { grid-template-columns: 1fr auto; gap: 6px; padding: 8px 10px; }
  .send-btn { padding: 8px 14px; }
  .msg .bubble { max-width: 94%; }
  .msg.center .bubble.embed { width: 100%; }
  .embed { width: 100%; }
  .embed.yt .yt-card { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .embed.yt .thumb { height: auto; aspect-ratio: 16/9; }
  .embed.yt .meta { padding: 10px 12px; }
  .embed.yt .play span { width: 40px; height: 40px; }
  .embed.yt-results { width: 100%; }
  .yt-item { grid-template-columns: 120px 1fr; }
  .yt-player { width: 86vw; }
  .poll { width: 94vw; }
}

@media (max-width: 420px) {
  :root { --people-strip-h: 72px; }
  .appbar { padding: 6px 10px; }
  .appbar .title { font-size: 16px; }
  .people-list { gap: 8px; }
  .avatar { height: 32px; width: 32px; }
  .avatar.lg { height: 36px; width: 36px; }
  .uname { font-size: 9px; max-width: 56px; }
  .msg .bubble { max-width: 92%; }
}

/* Horizontal people strip under header */
.people-strip { margin: 8px clamp(12px, 3vw, 20px) 0; padding: 6px 10px; height: var(--people-strip-h); min-height: var(--people-strip-h); max-height: var(--people-strip-h); overflow: hidden; display: flex; align-items: center; }
.people-list {
  display: flex; align-items: center; gap: 12px; overflow-x: auto; padding: 6px 8px; scroll-snap-type: x proximity; height: 100%; width: 100%;
}
.people-list::-webkit-scrollbar { height: 10px; }
.people-list::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 999px; }
.person {
  appearance: none; border: 0; background: transparent; color: var(--text);
  display: grid; justify-items: center; gap: 6px; padding: 4px 6px; cursor: pointer; scroll-snap-align: start;
}
.person:hover .avatar { filter: saturate(120%); }
.person.active .avatar { box-shadow: 0 0 0 2px color-mix(in oklab, var(--brand-2), white 8%), 0 6px 18px rgba(138,124,255,.32); }
.avatar { height: 36px; width: 36px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 30% 20%, var(--brand-1), var(--brand-2)); color: #0e1220; font-weight: 900; }
.avatar.lg { height: 48px; width: 48px; box-shadow: 0 6px 18px rgba(0,0,0,.25); border: 2px solid rgba(255,255,255,.18); }
.uname { font-size: 11px; color: var(--muted); max-width: 72px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }

/* Conversation area */
.conv-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--stroke); }
.conv-head { position: relative; padding-top: 28px; }
.conv-head .dragbar {
  position: absolute; left: 50%; top: 6px; transform: translateX(-50%);
  /* Large hit-area for easy tapping */
  width: 80px; height: 22px; background: transparent; border: 0; padding: 0; cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.conv-head .dragbar::after {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 48px; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,.75), rgba(255,255,255,.4));
  border: 1px solid rgba(255,255,255,.75);
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: transform .14s var(--ease), opacity .14s var(--ease);
}
.conv-head .dragbar:hover::after { transform: translate(-50%, -50%) scaleX(1.06); opacity: .95; }
.conversation.dragging .conv-head { user-select: none; }
.conversation.dragging, .conversation.dragging * { user-select: none; -webkit-user-select: none; }
.conversation.dragging .conv-head .dragbar { cursor: grabbing; }
.conversation.dragging { transition: none !important; }
.conversation.closing { opacity: .0; transform: translateY(120px); transition: transform .25s var(--ease), opacity .25s var(--ease); }
.conv-head .avatar { height: 40px; width: 40px; border: 2px solid rgba(255,255,255,.18); }
.conv-title { display: grid; line-height: 1.1; }
.conv-title strong { font-size: 16px; }
.conv-title small { color: var(--muted); }
.conv-body { padding: 16px; min-height: 0; overflow: auto; display: grid; align-content: start; gap: 6px; overscroll-behavior-y: contain; }
.conv-body, .conv-body * { list-style: none; }
/* Most content in conv-body sono .msg; nascondi qualunque altro child spurio */
.conv-body > :not(.msg) { display: none !important; }
/* Se dentro .msg esistono figli extra (es. indicatori), nascondili */
.conv-body .msg > :not(.bubble) { display: none !important; }
/* Evita spazio da elementi vuoti */
.conv-body > *:empty { display: none !important; }
.conv-body input[type="checkbox"],
.conv-body input[type="radio"] { display: none !important; }
.ar-stage { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.msg.meta { color: var(--muted); }
/* Typing indicator */
.msg.typing .bubble { background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03)); border: 1px dashed var(--stroke); color: var(--muted); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0% { opacity: .6 } 50% { opacity: 1 } 100% { opacity: .6 } }

/* Message bubbles */
.msg { display: grid; }
.msg .bubble { position: relative; max-width: min(72ch, 78%); padding: 10px 12px; border-radius: 14px; line-height: 1.35; word-break: break-word; overflow-wrap: anywhere; }
.msg.me { justify-items: end; }
.msg.me .bubble { background: linear-gradient(135deg, var(--brand-2), var(--brand-3)); color: #0e1220; box-shadow: 0 8px 20px rgba(138,124,255,.25); }
.msg.them { justify-items: start; }
.msg.them .bubble { background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04)); border: 1px solid var(--stroke); }
.msg.center { justify-items: center; }
.msg.center .bubble { padding: 0; background: transparent; border: 0; box-shadow: none; display: grid; place-items: center; }

/* Non mostrare bubble vuoti (es. eventi non supportati senza testo) */
.msg .bubble:empty { display: none !important; padding: 0 !important; border: 0 !important; }
/* E rimuovi anche il contenitore se il bubble è vuoto (browser moderni) */
.msg:has(> .bubble:empty) { display: none !important; }

/* Remove any decorative dots/handles on the left of messages */
.conversation .msg::before,
.conversation .msg::after,
.conversation .conv-body::before,
.conversation .conv-body::after { content: none !important; display: none !important; }

/* Center embeds */
.embed { width: min(680px, 92vw); }
.embed.yt .yt-card { position: relative; display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: center; width: 100%; border: 1px solid var(--stroke); border-radius: 14px; overflow: hidden; background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)); box-shadow: var(--shadow); }
.embed.yt .thumb { position: relative; height: 100px; background: #000; }
.embed.yt .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.embed.yt .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: radial-gradient(closest-side, rgba(0,0,0,.35), transparent 60%); }
.embed.yt .play span { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.92); color: #000; font-weight: 900; font-size: 0; }
.embed.yt .play span::after { content: '▶'; font-size: 18px; line-height: 1; transform: translateX(1px); }
.embed.yt .meta { padding-right: 12px; }
.embed.yt .title { font-weight: 700; margin: 6px 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.embed.yt .channel { color: var(--muted); font-size: 12px; }
.embed.yt .frame { position: relative; width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 14px; overflow: hidden; }

/* YouTube results list with red accent */
.embed.yt-results { width: min(720px, 94vw); }
.yt-list { display: grid; gap: 10px; }
.yt-item { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center; border: 2px solid #ff0000; border-radius: 12px; overflow: hidden; background: #1117; backdrop-filter: blur(6px); cursor: pointer; }
.yt-item .thumb { height: 88px; background: #000; }
.yt-item .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-item .meta { padding-right: 10px; }
.yt-item .title { font-weight: 700; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yt-item .channel { color: var(--muted); font-size: 12px; }
.yt-item:hover { filter: brightness(1.03); box-shadow: 0 8px 24px rgba(255,0,0,.16); }

/* YouTube player container (red accent) */
.yt-player { width: clamp(280px, 78vw, 540px); margin: 8px auto; border: 2px solid #ff0000; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); background: #000; }
.yt-player iframe { display: block; width: 100%; aspect-ratio: 16/9; border: 0; }
.yt-player .yt-meta { padding: 10px 12px; background: #111a; color: var(--text); display: grid; gap: 4px; border-top: 2px solid #ff0000; }
.yt-player .yt-title { font-weight: 800; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yt-player .yt-sub { color: var(--muted); font-size: 12px; display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.yt-player .dot { opacity: .6; }

/* Generic video embed */
.embed.video video { display: block; width: min(560px, 92vw); border: 2px solid var(--stroke); box-shadow: var(--shadow); }
.embed.image img { display: block; width: min(560px, 92vw); border: 2px solid var(--stroke); box-shadow: var(--shadow); }

/* Audio notes */
/* Modern audio message */
.audio-wrap.modern {
  --h: 46px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 14px; border: 1px solid var(--stroke);
  background: linear-gradient(180deg, var(--surface-2), rgba(255,255,255,0.02));
  box-shadow: 0 8px 20px rgba(0,0,0,.18) inset, 0 8px 24px rgba(0,0,0,.18);
  min-width: 220px; max-width: min(72ch, 92vw);
}
.audio-wrap.modern audio { display: none; }
.audio-wrap .audio-btn { height: var(--h); width: var(--h); border-radius: 12px; border: 1px solid var(--stroke); color: #0e1220; cursor: pointer; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand-2), var(--brand-3)); box-shadow: 0 10px 18px rgba(138,124,255,.25), 0 6px 12px rgba(255,106,213,.18); }
.audio-wrap .audio-btn:hover { filter: brightness(1.04) saturate(108%); }
.audio-wrap .audio-timeline { position: relative; height: 8px; border-radius: 999px; background: rgba(255,255,255,.10); overflow: hidden; cursor: pointer; }
.audio-wrap .audio-progress { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: linear-gradient(90deg, var(--brand-2), var(--brand-3)); box-shadow: 0 0 14px color-mix(in oklab, var(--brand-2), transparent 60%); }
.audio-wrap .audio-time { font-weight: 700; color: var(--muted); min-width: 46px; text-align: right; }

/* Poll */
.poll { width: min(560px, 92vw); border: 1px solid var(--stroke); border-radius: 12px; box-shadow: var(--shadow); background: linear-gradient(180deg, var(--surface), rgba(255,255,255,0.03)); overflow: hidden; }
.poll .q { font-weight: 800; padding: 12px 14px; border-bottom: 1px solid var(--stroke); }
.poll .opts { display: grid; }
.poll .opt { text-align: left; padding: 10px 14px; border: 0; background: transparent; color: var(--text); cursor: pointer; border-top: 1px solid var(--stroke); }
.poll .opt:hover { background: var(--surface); }
.poll .bar { position: relative; height: 6px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.poll .bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--brand-2), var(--brand-3)); transition: width .25s var(--ease); }
.poll .sub { display: inline-flex; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 6px; }
.msg.aiden { justify-items: start; }
.msg.aiden .bubble { background: linear-gradient(135deg, var(--brand-1), var(--ok)); color: #0e1220; box-shadow: 0 8px 20px rgba(124,246,255,.22); padding-top: 24px; }
.msg.aiden .bubble::before {
  content: 'Aiden';
  position: absolute; left: 10px; top: 6px;
  font-size: 10px; font-weight: 800; letter-spacing: .3px;
  color: #0e1220; background: rgba(255,255,255,.65);
  border: 1px solid rgba(255,255,255,.8); border-radius: 999px;
  padding: 2px 6px; line-height: 1;
}

/* Composer */
.composer { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--stroke); background: linear-gradient(180deg, var(--surface), rgba(255,255,255,0.03)); backdrop-filter: saturate(140%) blur(8px); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.input-wrap { position: relative; }
.composer-input { width: 100%; border: 1px solid var(--stroke); border-radius: 999px; padding: 12px 48px 12px 14px; background: linear-gradient(180deg, var(--surface-2), rgba(255,255,255,0.02)); color: var(--text); font: inherit; }
.send-icon { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); height: 36px; width: 36px; border-radius: 10px; border: 1px solid var(--stroke); display: grid; place-items: center; cursor: pointer; color: #0e1220; background: linear-gradient(135deg, var(--brand-2), var(--brand-3)); box-shadow: 0 10px 20px rgba(138,124,255,.25), 0 6px 14px rgba(255,106,213,.18); }
.send-icon:hover { filter: brightness(1.03) saturate(108%); }
.send-btn { padding: 10px 16px; border-radius: 999px; }

/* Reply preview above composer */
.reply-preview { margin: 4px 12px 0; border: 1px solid var(--stroke); border-radius: 10px; padding: 8px 12px; background: linear-gradient(180deg, var(--surface), rgba(255,255,255,0.03)); display: grid; gap: 4px; }
.reply-preview[hidden], .reply-preview:empty { display: none !important; margin: 0; padding: 0; border: 0; }
.reply-preview .rp-head { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.reply-preview .rp-who { font-weight: 800; color: var(--text); }
.reply-preview .rp-close { margin-left: auto; background: transparent; border: 0; color: var(--muted); cursor: pointer; height: 24px; width: 24px; border-radius: 6px; }
.reply-preview .rp-text { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Slash commands panel (appears above composer) */
.slash-panel { margin: 6px 12px 4px; border: 1px solid var(--stroke); border-radius: 12px; background: linear-gradient(180deg, var(--surface), rgba(255,255,255,0.03)); box-shadow: var(--shadow); display: none; overflow-y: auto; max-height: 168px; /* ~3 items */ }
.slash-panel.open { display: block; }
.slash-list { list-style: none; margin: 0; padding: 6px; display: grid; }
.slash-item { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 10px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer; }
.slash-item:hover, .slash-item.active { background: var(--surface); border-color: var(--stroke); }
.slash-item .cmd { font-weight: 800; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.slash-item .desc { color: var(--muted); font-size: 12px; }

/* Quote block inside message */
.bubble .quote { border-left: 3px solid color-mix(in oklab, var(--brand-2), white 10%); padding-left: 10px; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.bubble .quote .who { font-weight: 800; margin-right: 6px; color: var(--text); }
.msg.me .bubble .quote { background: rgba(255,255,255,.8); color: #0e1220; border-left-color: var(--brand-3); border-radius: 8px; padding: 8px 10px; }
.msg.me .bubble .quote .who { color: #0e1220; }
.msg.them .bubble .quote { background: rgba(255,255,255,.06); border-radius: 8px; padding: 8px 10px; }

/* Aiden centered responses: styled container */
.msg.center.aiden { justify-items: center; }
.msg.center.aiden .bubble {
  position: relative;
  padding: 12px 14px !important;
  border-radius: 12px !important;
  border: 1px solid var(--brand-2) !important;
  background: rgba(0,0,0,0.46) !important;
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(138,124,255,.18);
  max-width: min(680px, 92vw);
  word-break: break-word; overflow-wrap: anywhere;
}
.msg.center.aiden .bubble::before {
  content: 'Aiden';
  position: absolute; left: 12px; top: -10px;
  font-size: 10px; font-weight: 800; letter-spacing: .3px;
  color: #fff; background: color-mix(in oklab, var(--brand-2), black 40%);
  border: 1px solid var(--brand-2); border-radius: 999px;
  padding: 2px 6px; line-height: 1;
}

/* Chat page no-vertical-scroll layout */
html[data-page="chat"], html[data-page="chat"] body { height: 100dvh; }
html[data-page="chat"] body {
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr; /* header, people-strip, content */
}
html[data-page="chat"] .conversation { min-height: 0; height: 100%; }
html[data-page="chat"] .chat-layout { padding-top: 12px; padding-bottom: 12px; }
html[data-page="chat"] .chat-layout, html[data-page="chat"] .panel.conversation { min-height: 0; }

/* Search results items clickable */
.search-results .result-item { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); border: 1px solid transparent; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.search-results .result-item:hover { background: var(--surface); border-color: var(--stroke); }
/* AR effects */
.ar-stage .heart { position: absolute; bottom: 12px; left: 50%; font-size: 18px; transform: translateX(-50%); animation: rise 1.6s ease-in forwards; filter: drop-shadow(0 6px 10px rgba(0,0,0,.3)); }
@keyframes rise { 0% { transform: translate(-50%, 0) scale(.8); opacity: 0.0 } 10% { opacity: 1 } 100% { transform: translate(-50%, -220px) scale(1.4); opacity: 0 } }
.ar-stage .clap { position: absolute; bottom: 20px; right: 16px; font-size: 42px; animation: clapPop 1.2s ease-out forwards; filter: drop-shadow(0 8px 14px rgba(0,0,0,.35)); }
@keyframes clapPop { 0% { transform: scale(.4) rotate(-10deg); opacity: 0 } 40% { transform: scale(1.1) rotate(0deg); opacity: 1 } 70% { transform: scale(1) } 100% { transform: scale(.9); opacity: 0 } }
.ar-stage canvas.ar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Balloons */
.ar-stage .balloon { position: absolute; bottom: -60px; font-size: 26px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); animation: balloonRise 3.6s ease-in forwards; }
@keyframes balloonRise { 0% { transform: translateY(30px) scale(.9) } 50% { transform: translateY(-180px) translateX(-8px) } 100% { transform: translateY(-360px) translateX(8px); opacity: 0 } }
