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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: linear-gradient(180deg, #0a1628 0%, #0d2847 50%, #0f5156 100%);
  color: #ffffff;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

header {
  background: rgba(10, 22, 40, 0.95);
  backdrop-filter: blur(10px);
  color: white;
  padding: 1rem 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(31, 207, 212, 0.1);
  flex-shrink: 0;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #1fcfd4 0%, #0891b2 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(31, 207, 212, 0.3);
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, #1fcfd4 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.75rem;
  opacity: 0.7;
  color: #94a3b8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.info-card {
  background: rgba(15, 81, 86, 0.4);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(31, 207, 212, 0.2);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.info-card .icon {
  color: #1fcfd4;
}

.label {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-bottom: 0.125rem;
  color: #94a3b8;
}

.value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff;
}

.address-value {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #1fcfd4;
}

.address-with-copy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-btn-small {
  background: transparent;
  border: none;
  color: #1fcfd4;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: all 0.2s;
  border-radius: 4px;
}

.copy-btn-small:hover {
  opacity: 1;
  background: rgba(31, 207, 212, 0.1);
}

.btn-primary {
  background: linear-gradient(135deg, #1fcfd4 0%, #0891b2 100%);
  color: #0a1628;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(31, 207, 212, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(31, 207, 212, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: #1fcfd4;
  border: 2px solid #1fcfd4;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(31, 207, 212, 0.1);
}

.btn-icon {
  background: rgba(31, 207, 212, 0.1);
  border: 1px solid rgba(31, 207, 212, 0.3);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: #1fcfd4;
}

.btn-icon:hover {
  background: rgba(31, 207, 212, 0.2);
  transform: scale(1.05);
}

#main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  gap: 1.5rem;
  overflow: hidden;
  min-height: 0;
}

.sidebar {
  width: 320px;
  background: rgba(10, 22, 40, 0.7);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  border: 1px solid rgba(31, 207, 212, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(31, 207, 212, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 81, 86, 0.3);
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #1fcfd4;
}

.sidebar-header .btn-icon {
  background: linear-gradient(135deg, #1fcfd4 0%, #0891b2 100%);
  color: #0a1628;
  border: none;
}

.sidebar-header .btn-icon:hover {
  background: linear-gradient(135deg, #06b6d4 0%, #0e7490 100%);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.chat-list::-webkit-scrollbar {
  width: 6px;
}

.chat-list::-webkit-scrollbar-track {
  background: rgba(10, 22, 40, 0.3);
}

.chat-list::-webkit-scrollbar-thumb {
  background: rgba(31, 207, 212, 0.3);
  border-radius: 3px;
}

.chat-list::-webkit-scrollbar-thumb:hover {
  background: rgba(31, 207, 212, 0.5);
}

.chat-item {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(31, 207, 212, 0.05);
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}

.chat-item:hover {
  background: rgba(31, 207, 212, 0.05);
}

.chat-item.active {
  background: rgba(31, 207, 212, 0.1);
  border-left: 4px solid #1fcfd4;
}

.chat-item-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.chat-pubkey {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #1fcfd4;
  font-weight: 600;
  word-break: break-all;
}

.chat-time {
  font-size: 0.7rem;
  color: #64748b;
  white-space: nowrap;
}

.chat-preview {
  font-size: 0.875rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-container {
  flex: 1;
  background: rgba(10, 22, 40, 0.7);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  border: 1px solid rgba(31, 207, 212, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.chat-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(31, 207, 212, 0.1);
  background: rgba(15, 81, 86, 0.3);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.chat-header .icon {
  color: #1fcfd4;
}

.chat-header .label {
  color: #64748b;
}

.chat-header .value {
  font-family: 'Courier New', monospace;
  color: #1fcfd4;
  font-size: 0.9rem;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(13, 40, 71, 0.4);
  min-height: 0;
}

.messages-container::-webkit-scrollbar {
  width: 8px;
}

.messages-container::-webkit-scrollbar-track {
  background: rgba(10, 22, 40, 0.3);
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(31, 207, 212, 0.3);
  border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(31, 207, 212, 0.5);
}

.message {
  display: flex;
  gap: 0.75rem;
  max-width: 70%;
  animation: slideIn 0.3s ease-out;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-content {
  background: rgba(15, 81, 86, 0.5);
  backdrop-filter: blur(10px);
  padding: 0.875rem 1.125rem;
  border-radius: 12px;
  border: 1px solid rgba(31, 207, 212, 0.2);
}

.message.user .message-content {
  background: linear-gradient(135deg, #1fcfd4 0%, #0891b2 100%);
  color: #0a1628;
  border: none;
  box-shadow: 0 4px 12px rgba(31, 207, 212, 0.3);
}

.message-text {
  font-size: 0.9375rem;
  line-height: 1.5;
  margin-bottom: 0.375rem;
  color: #ffffff;
}

.message.user .message-text {
  color: #0a1628;
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.7;
  color: #94a3b8;
}

.message.user .message-time {
  color: #0a1628;
  opacity: 0.8;
}

.message-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.explorer-link {
  font-size: 0.7rem;
  color: #1fcfd4;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.explorer-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.message.user .explorer-link {
  color: #0a1628;
  opacity: 0.8;
}

.message.user .explorer-link:hover {
  opacity: 1;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  text-align: center;
  padding: 2rem;
}

.message-cost {
  padding: 0.875rem 1.5rem;
  border-top: 1px solid rgba(31, 207, 212, 0.1);
  background: rgba(15, 81, 86, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: #94a3b8;
  flex-shrink: 0;
}

.cost-value {
  color: #1fcfd4;
  font-weight: 600;
}

.message-form {
  padding: 1.25rem;
  border-top: 1px solid rgba(31, 207, 212, 0.1);
  background: rgba(10, 22, 40, 0.5);
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  padding: 0.875rem 1.125rem;
  border: 1px solid rgba(31, 207, 212, 0.2);
  border-radius: 10px;
  font-size: 0.9375rem;
  transition: all 0.2s;
  background: rgba(13, 40, 71, 0.5);
  color: #ffffff;
}

#message-input::placeholder {
  color: #64748b;
}

#message-input:focus {
  outline: none;
  border-color: #1fcfd4;
  background: rgba(13, 40, 71, 0.7);
  box-shadow: 0 0 0 3px rgba(31, 207, 212, 0.1);
}

.message-form .btn-primary {
  background: linear-gradient(135deg, #1fcfd4 0%, #0891b2 100%);
  color: #0a1628;
}

.message-form .btn-primary:hover {
  box-shadow: 0 6px 16px rgba(31, 207, 212, 0.4);
}

.message-form .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: linear-gradient(180deg, #0a1628 0%, #0d2847 100%);
  border: 1px solid rgba(31, 207, 212, 0.2);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 100%;
  padding: 2rem;
  animation: modalSlideIn 0.3s ease-out;
}

.modal-content.small {
  max-width: 500px;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.5rem;
  background: linear-gradient(135deg, #1fcfd4 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-header .btn-icon {
  color: #94a3b8;
  border-color: rgba(31, 207, 212, 0.2);
}

.qr-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: rgba(15, 81, 86, 0.3);
  border-radius: 12px;
  border: 1px solid rgba(31, 207, 212, 0.2);
}

#qr-canvas {
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.address-display {
  background: rgba(15, 81, 86, 0.4);
  border: 1px solid rgba(31, 207, 212, 0.2);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.address-display p {
  font-family: 'Courier New', monospace;
  color: #1fcfd4;
  font-size: 1.125rem;
  word-break: break-all;
  text-align: center;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.address-actions {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.btn-copy-address {
  background: linear-gradient(135deg, #1fcfd4 0%, #0891b2 100%);
  color: #0a1628;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(31, 207, 212, 0.3);
}

.btn-copy-address:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(31, 207, 212, 0.4);
}

.flex-1 {
  flex: 1;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.form-group input {
  width: 100%;
  padding: 0.875rem 1.125rem;
  border: 1px solid rgba(31, 207, 212, 0.2);
  border-radius: 10px;
  font-size: 0.9375rem;
  font-family: 'Courier New', monospace;
  transition: all 0.2s;
  background: rgba(13, 40, 71, 0.5);
  color: #ffffff;
}

.form-group input::placeholder {
  color: #64748b;
}

.form-group input:focus {
  outline: none;
  border-color: #1fcfd4;
  background: rgba(13, 40, 71, 0.7);
  box-shadow: 0 0 0 3px rgba(31, 207, 212, 0.1);
}

@media (max-width: 768px) {
  body {
    overflow: auto;
  }

  #app {
    height: auto;
    min-height: 100vh;
  }

  .header-content {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  #main-content {
    flex-direction: column;
    padding: 1rem;
    overflow: auto;
  }

  .sidebar {
    width: 100%;
    max-height: 300px;
  }

  .chat-container {
    min-height: 500px;
  }

  .message {
    max-width: 85%;
  }
}
