:root {
  --bg: #12081c;
  --bg2: #1a0a28;
  --accent: #a855f7;
  --accent2: #c084fc;
  --text: #f3e8ff;
  --muted: #c4b5d6;
  --danger: #f87171;
  --tg-bg: var(--tg-theme-bg-color, var(--bg));
  --tg-text: var(--tg-theme-text-color, var(--text));
  --tg-btn: var(--tg-theme-button-color, var(--accent));
  --tg-btn-text: var(--tg-theme-button-text-color, #fff);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--tg-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#app {
  max-width: 390px;
  margin: 0 auto;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 4px 4px;
  flex-shrink: 0;
  z-index: 2;
}
.greet { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.01em; }
.stage {
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 999px;
  padding: 3px 10px;
}

.stage-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  min-height: 0;
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45), 0 0 0 1px rgba(168,85,247,0.22);
  background: #1a0a28;
}

#stage3d {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
  touch-action: none;
}

.bubble {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  background: rgba(30, 12, 48, 0.88);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--text);
  backdrop-filter: blur(8px);
  max-height: 26%;
  overflow-y: auto;
  z-index: 2;
  pointer-events: auto;
}

.dock {
  flex-shrink: 0;
  padding: 8px 0 14px;
}
.status {
  min-height: 1.1em;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  padding: 0 4px;
}
.status.err { color: var(--danger); }
.row {
  display: flex;
  gap: 8px;
  align-items: center;
}
#textInput {
  flex: 1;
  min-width: 0;
  height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(168, 85, 247, 0.4);
  background: rgba(20, 8, 32, 0.9);
  color: var(--text);
  padding: 0 14px;
  font-size: 1rem;
  outline: none;
}
#textInput:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.25);
}
.icon-btn, .send-btn {
  height: 48px;
  width: 48px;
  border: none;
  border-radius: 14px;
  font-size: 1.25rem;
  cursor: pointer;
  background: rgba(168, 85, 247, 0.2);
  color: var(--text);
  border: 1px solid rgba(168, 85, 247, 0.4);
}
.send-btn {
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  border-color: transparent;
  font-weight: 700;
}
.icon-btn.rec {
  background: #7f1d1d;
  border-color: #ef4444;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.icon-btn:disabled, .send-btn:disabled, #textInput:disabled {
  opacity: 0.55;
}
