/* Public chat — widget + full page */
.public-chat-root {
  --chat-panel-w: 400px;
  --chat-panel-h: calc(100dvh - 1.75rem);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.public-chat-root * {
  box-sizing: border-box;
}

/* Floating launcher */
.public-chat-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9000;
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--truth, #00ff88), #00cc6a);
  color: #0b0b12;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0, 255, 136, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.public-chat-launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px rgba(0, 255, 136, 0.45);
}

.public-chat-launcher .material-symbols-outlined {
  font-size: 1.5rem;
}

.public-chat-launcher[hidden],
.public-chat-overlay[hidden] {
  display: none !important;
}

/* Overlay + panel (widget mode) */
.public-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 8999;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 0.75rem 1rem 1rem;
}

.public-chat-panel {
  width: var(--chat-panel-w);
  height: var(--chat-panel-h);
  max-width: calc(100vw - 2rem);
  max-height: none;
  background: var(--surface, #14141f);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

.public-chat-panel--page {
  width: 100%;
  max-width: 720px;
  height: 100%;
  min-height: calc(100dvh - 11rem);
  max-height: none;
  margin: 0 auto;
}

/* Header */
.public-chat-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: var(--surface-2, #1c1c2a);
  flex-shrink: 0;
}

.public-chat-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.public-chat-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #fff);
}

.public-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.public-chat-live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--truth, #00ff88);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.public-chat-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--truth, #00ff88);
  animation: public-chat-pulse 1.5s ease infinite;
}

@keyframes public-chat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.public-chat-icon-btn {
  background: transparent;
  border: none;
  color: var(--muted, #8a8aa0);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.35rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.public-chat-icon-btn:hover {
  color: var(--text, #fff);
  background: rgba(255, 255, 255, 0.06);
}

.public-chat-open-full {
  font-size: 0.75rem;
  color: var(--truth, #00ff88);
  text-decoration: none;
  display: inline-block;
  margin-top: 0.35rem;
}

.public-chat-open-full:hover {
  text-decoration: underline;
}

/* Identity bar */
.public-chat-identity {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.public-chat-identity--google {
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
}

.public-chat-nick-row {
  display: flex;
  gap: 0.35rem;
}

.public-chat-nick-input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.65rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: var(--bg, #0b0b12);
  color: var(--text, #fff);
  font-size: 0.85rem;
  font-family: inherit;
}

.public-chat-nick-input:focus {
  outline: none;
  border-color: rgba(0, 255, 136, 0.35);
}

.public-chat-btn {
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  border: none;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.public-chat-btn--primary {
  background: var(--truth, #00ff88);
  color: #0b0b12;
  font-weight: 600;
}

.public-chat-btn--ghost {
  background: transparent;
  color: var(--muted, #8a8aa0);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.public-chat-btn--google {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  background: #fff;
  color: #333;
  font-weight: 500;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
}

.public-chat-btn--google:hover {
  background: #f5f5f5;
}

.public-chat-google-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.public-chat-google-hint {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted, #8a8aa0);
  text-align: center;
}

.public-chat-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.public-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface, #14141f);
}

.public-chat-avatar--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2, #1c1c2a);
  color: var(--muted, #8a8aa0);
  font-size: 0.85rem;
  font-weight: 600;
}

.public-chat-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text, #fff);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-chat-verified {
  color: var(--truth, #00ff88);
  font-size: 0.75rem;
}

/* Messages */
.public-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg, #0b0b12);
}

.public-chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted, #8a8aa0);
  font-size: 0.85rem;
  padding: 2rem 1rem;
}

.public-chat-msg {
  display: flex;
  gap: 0.4rem;
  max-width: 88%;
}

.public-chat-msg--own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.public-chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 1.1rem;
}

.public-chat-msg-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.public-chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--muted, #8a8aa0);
}

.public-chat-msg--own .public-chat-msg-meta {
  justify-content: flex-end;
}

.public-chat-msg-bubble {
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.public-chat-msg--other .public-chat-msg-bubble {
  background: var(--surface-2, #1c1c2a);
  color: var(--text, #fff);
  border-bottom-left-radius: 0.2rem;
}

.public-chat-msg--own .public-chat-msg-bubble {
  background: rgba(0, 255, 136, 0.15);
  color: var(--text, #fff);
  border: 1px solid rgba(0, 255, 136, 0.25);
  border-bottom-right-radius: 0.2rem;
}

.public-chat-msg-bubble .public-chat-link {
  color: var(--truth, #00ff88);
  text-decoration: underline;
  word-break: break-all;
}

.public-chat-msg-bubble .public-chat-link:hover {
  opacity: 0.85;
}

.public-chat-msg--own .public-chat-msg-bubble .public-chat-link {
  color: #7dffc0;
}

/* Composer */
.public-chat-composer {
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: var(--surface-2, #1c1c2a);
  flex-shrink: 0;
  position: relative;
}

.public-chat-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
}

.public-chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 1.25rem;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: var(--bg, #0b0b12);
  color: var(--text, #fff);
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}

.public-chat-input:focus {
  outline: none;
  border-color: rgba(0, 255, 136, 0.35);
}

.public-chat-send {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: var(--truth, #00ff88);
  color: #0b0b12;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.public-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.public-chat-send .material-symbols-outlined {
  font-size: 1.1rem;
}

.public-chat-error {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--lie, #ff3366);
}

/* Emoji picker */
.public-chat-emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0.75rem;
  right: 0.75rem;
  margin-bottom: 0.35rem;
  padding: 0.5rem;
  background: var(--surface, #14141f);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 0.75rem;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.15rem;
  max-height: 160px;
  overflow-y: auto;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

.public-chat-emoji-picker[hidden] {
  display: none !important;
}

.public-chat-emoji-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.35rem;
  line-height: 1;
}

.public-chat-emoji-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Full page layout */
body.chat-page .shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.chat-page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0 1rem;
  min-height: 0;
}

.chat-page-hero {
  text-align: center;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-page-hero h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  text-align: center;
  width: 100%;
}

.chat-page-hero .section-lead {
  margin: 0 auto;
  font-size: 0.9rem;
  text-align: center;
  max-width: 36rem;
}

.chat-page-main > .container:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.chat-page #public-chat-page {
  flex: 1;
  display: flex;
  min-height: 0;
}

body.chat-page #public-chat-page.public-chat-root {
  width: 100%;
}

@media (max-width: 600px) {
  .public-chat-overlay {
    padding: 0;
  }

  .public-chat-panel {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .public-chat-launcher {
    right: 1rem;
    bottom: 1rem;
  }

  .public-chat-panel--page {
    min-height: calc(100dvh - 10rem);
  }
}
