:root {
  --bg: #030305;
  --cyan: #38e8e1;
  --violet: #7c3aed;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #f2f2f5;
  --text-dim: #9a9aa5;
  --danger: #ef4a6b;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 0%, rgba(124, 58, 237, 0.10), transparent 45%),
    radial-gradient(circle at 80% 100%, rgba(56, 232, 225, 0.08), transparent 45%),
    var(--bg);
}

.hidden { display: none !important; }

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

code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  word-break: break-all;
}

/* ---------- Aura perimetral ---------- */
#auraOverlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  transition: box-shadow 0.5s ease;
}
#auraOverlay.aura-typing {
  box-shadow: inset 0 0 60px 6px rgba(56, 232, 225, 0.35);
}
#auraOverlay.aura-recording {
  box-shadow: inset 0 0 70px 10px rgba(239, 74, 107, 0.4);
}

/* ---------- Layout general ---------- */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  padding: env(safe-area-inset-top, 0) 16px env(safe-area-inset-bottom, 0);
  position: relative;
}

.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- Glassmorphism ---------- */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
}

/* ---------- Home ---------- */
#screen-home {
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding-top: 40px;
  padding-bottom: 40px;
}

.logo-full {
  width: min(280px, 80vw);
  height: auto;
  margin: 0 auto 4px;
  display: block;
  filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.4));
}

.logo-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.4));
}

.tagline { color: var(--text-dim); margin: 0; font-size: 0.95rem; }

.home-actions {
  width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.btn-primary, .btn-secondary {
  padding: 14px 20px;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #05050a;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text);
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }

#groupSizeWrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
#groupSizeWrap label { font-size: 0.85rem; color: var(--text-dim); text-align: left; }
#groupSize {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-size: 1rem;
}

.home-links { display: flex; gap: 18px; }

.link-btn {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); }

/* ---------- Chat ---------- */
#screen-chat { padding-top: 12px; padding-bottom: 12px; gap: 12px; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  position: sticky;
  top: 8px;
  z-index: 10;
}
.room-info { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-dim); }
.dot-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px 2px rgba(56,232,225,0.6);
}
.chat-actions { display: flex; gap: 6px; }
.chat-actions button {
  width: 36px; height: 36px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  font-size: 1rem;
}
#btnDestroy { color: var(--danger); }

.invite-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.invite-banner code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--cyan);
}
.invite-banner button {
  background: rgba(56,232,225,0.12);
  color: var(--cyan);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 100px;
}

.msg-card {
  max-width: 78%;
  padding: 12px 14px;
  animation: floatIn 0.25s ease;
}
.msg-card.mine { align-self: flex-end; background: rgba(56,232,225,0.07); border-color: rgba(56,232,225,0.18); }
.msg-card.theirs { align-self: flex-start; }
.msg-card.system { align-self: center; background: transparent; border: none; color: var(--text-dim); font-size: 0.78rem; }

.msg-body { font-size: 0.95rem; line-height: 1.4; word-break: break-word; }
.msg-body img { max-width: 100%; border-radius: 14px; display: block; }
.msg-body audio { width: 220px; max-width: 100%; }

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.68rem;
  color: var(--text-dim);
}
.btn-seen {
  color: var(--cyan);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(56,232,225,0.1);
}
.btn-seen[disabled] { opacity: 0.4; pointer-events: none; }

@keyframes floatIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes particleDissolve {
  0% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translateY(-15px) scale(0.92); filter: blur(6px); }
}
.msg-card.dissolving {
  animation: particleDissolve 0.6s ease forwards;
  pointer-events: none;
}

/* ---------- Orb dock ---------- */
.orb-dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(to top, rgba(3,3,5,0.95), rgba(3,3,5,0));
  z-index: 20;
}
.glass-orb {
  width: 100%;
  max-width: 528px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 16px;
  border-radius: 30px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
#textInput {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  min-width: 0;
}
#textInput::placeholder { color: var(--text-dim); }

.orb-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  background: rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.orb-send {
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #05050a;
}
#btnRecord.active {
  background: var(--danger);
  color: #fff;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,74,107,0.5); }
  50% { box-shadow: 0 0 0 10px rgba(239,74,107,0); }
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--danger);
  padding: 8px 16px;
  border-radius: 14px;
  background: rgba(239,74,107,0.08);
}
.recording-indicator button {
  color: var(--text-dim);
  text-decoration: underline;
  font-size: 0.78rem;
}

/* ---------- Error screen ---------- */
#screen-error { align-items: center; justify-content: center; text-align: center; gap: 16px; }
#screen-error .glass-card { padding: 28px; max-width: 380px; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal {
  max-width: 420px;
  width: 100%;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal h2 { margin: 0; font-size: 1.3rem; }
.modal p { margin: 0; color: var(--text-dim); font-size: 0.9rem; line-height: 1.5; }
.modal ul { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 0.85rem; }
.modal ul code { color: var(--cyan); }

.donate-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
}
.donate-row span { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.donate-row code { font-size: 0.85rem; color: var(--cyan); }
.donate-row button {
  align-self: flex-start;
  margin-top: 2px;
  padding: 6px 14px;
  border-radius: 10px;
  background: rgba(56,232,225,0.12);
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 600;
}

.modal-close { margin-top: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,20,26,0.95);
  border: 1px solid var(--glass-border);
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 0.82rem;
  z-index: 80;
  animation: floatIn 0.2s ease;
}

@media (min-width: 640px) {
  #app { padding-top: 24px; }
}
