@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg: #0c0c0e;
  --surface: #151518;
  --surface-raised: #1c1c21;
  --border: #2a2a30;
  --border-focus: #d4a843;
  --text: #e8e6e1;
  --text-dim: #7a7872;
  --accent: #d4a843;
  --accent-glow: rgba(212, 168, 67, 0.15);
  --accent-soft: #b8923a;
  --danger: #c45252;
  --radius: 10px;
  --mono: 'DM Mono', monospace;
  --sans: 'Outfit', system-ui, sans-serif;
}

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

html, body, #root {
  height: 100%;
  width: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== JOIN SCREEN ========== */

.join-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(212, 168, 67, 0.06) 0%, transparent 60%),
    var(--bg);
}

.join-card {
  width: 100%;
  max-width: 380px;
  animation: card-in 0.5s ease-out both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.join-header {
  text-align: center;
  margin-bottom: 36px;
}

.signal-icon {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  margin-bottom: 14px;
  height: 28px;
}

.signal-icon .bar {
  display: block;
  width: 5px;
  background: var(--accent);
  border-radius: 2px;
  animation: signal-pulse 1.8s ease-in-out infinite;
}

.bar-1 {
  height: 8px;
  animation-delay: 0s !important;
}
.bar-2 {
  height: 16px;
  animation-delay: 0.15s !important;
}
.bar-3 {
  height: 24px;
  animation-delay: 0.3s !important;
}

@keyframes signal-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.app-title {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.5px;
  color: var(--text);
}

.app-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 500;
}

/* Form */
.join-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  font-weight: 500;
}

.field input {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.field input::placeholder {
  color: var(--text-dim);
  opacity: 0.5;
}

.field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Error */
.error-msg {
  font-size: 13px;
  color: var(--danger);
  background: rgba(196, 82, 82, 0.08);
  border: 1px solid rgba(196, 82, 82, 0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
  animation: shake 0.35s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Button */
.join-btn {
  margin-top: 6px;
  background: var(--accent);
  color: #0c0c0e;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
  border: none;
  border-radius: var(--radius);
  padding: 16px 24px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  position: relative;
  overflow: hidden;
}

.join-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.join-btn:active:not(:disabled) {
  transform: translateY(0);
}

.join-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.connecting-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot-pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #0c0c0e;
  border-radius: 50%;
  animation: dot-blink 1s ease-in-out infinite;
}

@keyframes dot-blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ========== CHAT SCREEN ========== */

.chat-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100dvh;
  background: var(--bg);
  animation: chat-fade-in 0.35s ease-out both;
}

@keyframes chat-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.chat-channel-hash {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--accent);
  flex-shrink: 0;
}

.chat-channel-name {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-live-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
  animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(74, 222, 128, 0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 2px rgba(74, 222, 128, 0.2); }
}

.chat-user-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Empty state */
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  animation: empty-in 0.5s ease-out 0.2s both;
}

@keyframes empty-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-empty strong {
  color: var(--accent);
  font-weight: 500;
}

.chat-empty-sub {
  font-size: 12px;
  margin-top: 4px;
  opacity: 0.5;
}

.chat-empty-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  margin-bottom: 14px;
}

.wave-bar {
  display: block;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: wave-idle 1.4s ease-in-out infinite;
}

.wb-1 { height: 6px; animation-delay: 0s; }
.wb-2 { height: 14px; animation-delay: 0.12s; }
.wb-3 { height: 20px; animation-delay: 0.24s; }
.wb-4 { height: 14px; animation-delay: 0.36s; }
.wb-5 { height: 6px; animation-delay: 0.48s; }

@keyframes wave-idle {
  0%, 100% { transform: scaleY(0.5); opacity: 0.3; }
  50% { transform: scaleY(1); opacity: 0.8; }
}

/* Chat bubbles */
.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: bubble-in 0.2s ease-out both;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble-own {
  align-self: flex-end;
  background: var(--accent);
  color: #0c0c0e;
  border-bottom-right-radius: 3px;
}

.chat-bubble-peer {
  align-self: flex-start;
  background: var(--surface-raised);
  color: var(--text);
  border-bottom-left-radius: 3px;
}

.chat-bubble-sender {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin-bottom: 3px;
}

.chat-bubble-body {
  font-family: var(--sans);
}

/* Input bar */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: var(--surface-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
}

.chat-input::placeholder {
  color: var(--text-dim);
  opacity: 0.5;
}

.chat-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-send-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #0c0c0e;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  transform: scale(1.05);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.chat-send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
