:root {
  --bg: #09090b;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --surface-elevated: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.1);
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.3);
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.3);
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --error: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Rethink Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  width: 320px;
  height: 470px;
  overflow: hidden;
}

.container {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 470px;
  overflow: hidden;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
}

.logo-text {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), #a1a1aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.bits-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bits-balance:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.bits-icon { color: var(--accent); }

h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.voice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 120px;
  overflow-y: auto;
}

.voice-grid::-webkit-scrollbar {
  width: 4px;
}

.voice-grid::-webkit-scrollbar-track {
  background: transparent;
}

.voice-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
}

.voice-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.25s ease;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.voice-card:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35), 0 0 30px rgba(139, 92, 246, 0.1);
}

.voice-card:hover .voice-avatar {
  background: rgba(139, 92, 246, 0.18);
}

.voice-card.selected {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4), 0 0 30px rgba(139, 92, 246, 0.15);
}

.voice-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.voice-card.selected .voice-avatar {
  background: rgba(139, 92, 246, 0.2);
}

.voice-name {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.voice-card.selected .voice-name {
  color: var(--text-primary);
}

.message-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  width: 100%;
  min-height: 80px;
  height: 80px;
  transition: all 0.2s ease;
  line-height: 1.5;
}

.message-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.message-input::placeholder {
  color: var(--text-tertiary);
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.char-count {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.char-count.warning { color: var(--warning); }
.char-count.error { color: var(--error); }

.bits-required {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: 100px;
  padding: 4px 10px;
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
}

.sender-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s ease;
}

.sender-row:focus-within {
  border-color: var(--border-hover);
}

.sender-label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.sender-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  width: 0;
  flex: 1;
  min-width: 0;
}

.sender-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.donate-btn {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border: none;
  border-radius: 10px;
  padding: 12px;
  color: white;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.donate-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s ease;
}

.donate-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.donate-btn:hover:not(:disabled)::before {
  transform: translateX(100%);
}

.donate-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.donate-btn:disabled {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
}

.donate-btn .bits-icon {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.9);
}

.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}

.success-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.success-content {
  text-align: center;
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-overlay.show .success-content {
  transform: scale(1);
}

.success-icon {
  font-size: 56px;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(16, 185, 129, 0.4));
}

.success-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}

.confetti {
  position: fixed;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 101;
}

@keyframes fall {
  to {
    transform: translateY(400px) rotate(720deg);
    opacity: 0;
  }
}

.loading {
  position: relative;
  width: 320px;
  height: 470px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  will-change: transform;
}

.loading-blob:nth-child(1) {
  width: 140px;
  height: 140px;
  background: rgba(139, 92, 246, 0.25);
  animation: blobFloat1 4s cubic-bezier(0.45, 0.05, 0.2, 1) infinite alternate;
}

.loading-blob:nth-child(2) {
  width: 110px;
  height: 110px;
  background: rgba(99, 102, 241, 0.2);
  animation: blobFloat2 5s cubic-bezier(0.45, 0.05, 0.2, 1) infinite alternate;
}

.loading-blob:nth-child(3) {
  width: 90px;
  height: 90px;
  background: rgba(16, 185, 129, 0.2);
  animation: blobFloat3 3.6s cubic-bezier(0.45, 0.05, 0.2, 1) infinite alternate;
}

@keyframes blobFloat1 {
  0% { transform: translate(-30px, 20px) scale(0.8); opacity: 0.4; }
  100% { transform: translate(30px, -40px) scale(1.3); opacity: 0.8; }
}

@keyframes blobFloat2 {
  0% { transform: translate(20px, -30px) scale(1.1); opacity: 0.5; }
  100% { transform: translate(-40px, 30px) scale(0.7); opacity: 0.9; }
}

@keyframes blobFloat3 {
  0% { transform: translate(-10px, -10px) scale(0.9); opacity: 0.3; }
  100% { transform: translate(40px, 20px) scale(1.4); opacity: 0.7; }
}

.loading-ring {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.06);
  border-top-color: var(--primary);
  animation: ringSpin 1s cubic-bezier(0.45, 0.05, 0.2, 1) infinite;
  z-index: 1;
}

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