/* ── UCLEUS Phanzo standalone chat page ── */

/* Strict chat shell: lock body, all scroll lives inside .phanzo-messages */
html, body.phanzo-body {
  height: 100%;
  overflow: hidden;
}

.phanzo-body {
  background: var(--dark);
}

.phanzo-body::before,
.phanzo-body::after { content: none; }

.phanzo-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background: var(--dark);
  position: relative;
  z-index: 1;
}

@media (min-width: 560px) {
  .phanzo-page {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ── Topbar with corner star ── */
.phanzo-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,13,20,0.92);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  padding-top: calc(10px + env(safe-area-inset-top));
}

.phanzo-back {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: rgba(124,58,237,0.12);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all 0.2s;
  flex-shrink: 0;
}
.phanzo-back:hover { background: rgba(124,58,237,0.25); color:#fff; }
.phanzo-back svg { width:18px; height:18px; }

.phanzo-identity {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.phanzo-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 4px;
  color: #fff;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phanzo-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s ease;
}
.phanzo-sub::before {
  content: '●';
  display: inline-block;
  font-size: 8px;
  margin-right: 6px;
  transform: translateY(-1px);
  color: var(--purple-light);
  transition: color 0.3s ease;
}
.phanzo-sub[data-mode="idle"]     { color: #4ade80; }
.phanzo-sub[data-mode="idle"]::before     { color: #4ade80; }
.phanzo-sub[data-mode="speaking"] { color: var(--neon); }
.phanzo-sub[data-mode="speaking"]::before { color: var(--neon); }
.phanzo-sub[data-mode="error"]    { color: #fca5a5; }
.phanzo-sub[data-mode="error"]::before    { color: #fca5a5; }
.phanzo-sub[data-mode="success"]  { color: #4ade80; }
.phanzo-sub[data-mode="success"]::before  { color: #4ade80; }

.phanzo-voice-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(124,58,237,0.10);
  color: var(--muted);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.phanzo-voice-toggle svg { width: 14px; height: 14px; }
.phanzo-voice-toggle .icon-voice-on  { display: none; }
.phanzo-voice-toggle .icon-voice-off { display: inline; }
.phanzo-voice-toggle.on {
  border-color: var(--neon);
  background: rgba(168,85,247,0.18);
  color: #fff;
  box-shadow: 0 0 14px rgba(124,58,237,0.45);
}
.phanzo-voice-toggle.on .icon-voice-on  { display: inline; }
.phanzo-voice-toggle.on .icon-voice-off { display: none; }

/* Corner star badge — lives in topbar */
.phanzo-star-badge {
  width:  clamp(64px, 18vw, 80px);
  height: clamp(64px, 18vw, 80px);
  flex-shrink: 0;
  position: relative;
  filter: drop-shadow(0 0 14px rgba(124,58,237,0.45));
}
.phanzo-star-badge canvas {
  width:  100% !important;
  height: 100% !important;
  display: block;
}

/* ── Conversation column ── */
.phanzo-conversation {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-error-banner {
  display: none;
  margin: 12px 16px 0;
}

.phanzo-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Bottom-anchor trick: short conversations sit near the composer */
.phanzo-messages > .msg:first-child,
.phanzo-messages > .chat-chip-row:first-child {
  margin-top: auto;
}

.phanzo-messages::-webkit-scrollbar { width: 4px; }
.phanzo-messages::-webkit-scrollbar-track { background: transparent; }
.phanzo-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Quick-reply chips */
.chat-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 4px 38px; /* align under bot avatar (28px + 10px gap) */
  margin-top: -4px;
  animation: msgIn 0.25s ease;
}
.chat-chip {
  background: rgba(124,58,237,0.10);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.chat-chip:hover {
  background: rgba(124,58,237,0.22);
  border-color: var(--neon);
  color: #fff;
  transform: translateY(-1px);
}
.chat-chip:active { transform: translateY(0); }

/* Disabled banner */
.phanzo-disabled {
  display: none;
  margin: 0 16px 12px;
  padding: 12px 16px;
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.25);
  border-radius: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: #4ade80;
  text-align: center;
  letter-spacing: 1px;
  line-height: 1.5;
}
.phanzo-disabled.error {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.3);
  color: #fca5a5;
}

/* ── Composer ── */
.phanzo-inputbar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(13,13,20,0.92);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.phanzo-input {
  flex: 1;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 44px;
  max-height: 110px;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.phanzo-input:focus { border-color: var(--purple); }
.phanzo-input::placeholder { color: var(--muted); }

.phanzo-send {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}
.phanzo-send:hover { transform: scale(1.05); }
.phanzo-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.phanzo-send svg { width: 18px; height: 18px; color: #fff; }

/* Small screens — drop the VOICE word, keep just the icon */
@media (max-width: 380px) {
  .phanzo-voice-toggle .voice-label { display: none; }
  .phanzo-name { font-size: 20px; letter-spacing: 3px; }
  .phanzo-topbar { gap: 8px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); }
}
