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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.container {
  max-width: 900px;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: fadeIn 0.6s ease-out;
}

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

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 60px 40px;
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.3; }
}

.header h1 {
  font-size: 3em;
  margin-bottom: 15px;
  position: relative;
  z-index: 1;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.header p {
  font-size: 1.2em;
  opacity: 0.95;
  position: relative;
  z-index: 1;
}

.content {
  padding: 50px 40px;
}

.welcome-text {
  text-align: center;
  margin-bottom: 40px;
  color: #333;
  font-size: 1.1em;
  line-height: 1.6;
}

.links-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
  margin-bottom: 40px;
}

.link-card {
  background: white;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.link-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.link-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);
  border-color: #667eea;
}

.link-card:hover::before {
  opacity: 0.05;
}

.link-card-content {
  position: relative;
  z-index: 1;
}

.icon {
  font-size: 3em;
  margin-bottom: 15px;
  display: block;
}

.link-card h3 {
  color: #667eea;
  margin-bottom: 12px;
  font-size: 1.4em;
}

.link-card p {
  color: #666;
  margin-bottom: 20px;
  line-height: 1.6;
}

.link-button {
  display: inline-block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px 30px;
  border-radius: 25px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.link-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.footer {
  text-align: center;
  padding: 30px;
  background: #f8f9fa;
  color: #666;
  font-style: italic;
  border-top: 1px solid #e0e0e0;
}

.chat-section {
  margin-top: 40px;
}

.chat-title {
  text-align: center;
  color: #667eea;
  font-size: 2em;
  margin-bottom: 25px;
}

.chat-container {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.chat-messages {
  height: 400px;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  scroll-behavior: smooth;
}

.chat-empty {
  text-align: center;
  color: #999;
  padding: 60px 20px;
  font-size: 1.1em;
}

/* Само сообщение теперь в flex с аватаркой */
.chat-message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
  animation: slideIn 0.3s ease-out;
}

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

.chat-message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.chat-message-name {
  font-weight: 600;
  color: #667eea;
  font-size: 0.95em;
}

.chat-message-time {
  font-size: 0.8em;
  color: #999;
}

.chat-message-text {
  color: #333;
  line-height: 1.5;
  word-wrap: break-word;
}

/* Основной контейнер ввода — теперь всегда в столбик */
.chat-input-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: white;
  border-top: 1px solid #e0e0e0;
}

/* Поле имени — минималистичная полоска с подчёркиванием */
.chat-name-input {
  width: 220px; /* Короткое поле */
  height: 36px;
  padding: 0 8px 0 0; /* Только справа отступ */
  border: none;
  border-bottom: 2px solid #ccc; /* Только нижняя линия */
  background: transparent;
  font-size: 0.95em;
  color: #555;
  align-self: flex-start; /* Прижато к левому краю */
  transition: border-color 0.3s ease;
}

.chat-name-input:focus {
  outline: none;
  border-bottom-color: #667eea;
}

.chat-name-input::placeholder {
  color: #aaa;
  opacity: 1;
}

/* Поле сообщения */
.chat-message-input {
  flex: 1;
  min-height: 50px;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1em;
  resize: none;
  transition: all 0.3s ease;
}

.chat-message-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Кнопка отправки — стрелочка */
.chat-send-button {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end; /* Кнопка справа внизу */
  position: relative;
}

.chat-send-button::after {
  content: '→';
  font-size: 1.4em;
  transition: transform 0.2s ease;
}

.chat-send-button:hover:not(:disabled)::after {
  transform: translateX(4px);
}

.chat-send-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.chat-send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.decorative-line {
  height: 4px;
  background: linear-gradient(90deg, transparent, #667eea, #764ba2, transparent);
  margin: 40px 0;
  border-radius: 2px;
}

/* Адаптивность */
@media (max-width: 768px) {
  .header h1 { font-size: 2em; }
  .content { padding: 30px 20px; }
  .links-container { grid-template-columns: 1fr; }

  .chat-messages { height: 300px; }

  .chat-name-input {
    width: 100%; /* На мобиле — на всю ширину */
    padding: 0 0 8px 0;
    font-size: 1em;
  }

  .chat-message-input {
    min-height: 56px;
  }

  .chat-send-button {
    width: 56px;
    height: 56px;
  }
}

@media (max-width: 480px) {
  .chat-input-container { padding: 15px; }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 15px 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  gap: 12px;
}

.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4em;
  font-weight: bold;
}

.profile-name {
  font-size: 1.1em;
  color: #333;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Новая плашка fingerprint — серый круг с иконкой информации через SVG path */
.fingerprint-info {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #888;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  position: relative;
}

.fingerprint-tooltip {
  display: none;
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 12px;
  border-radius: 8px;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  font-size: 0.9em;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  line-height: 1.5;
}

.fingerprint-info:hover .fingerprint-tooltip {
  display: block;
}

#identificationLoader {
  text-align: center;
  padding: 60px;
  color: #666;
  font-size: 1.2em;
}

.fingerprint-info svg {
  width: 18px;
  height: 18px;
}

/* Аватарка у каждого сообщения */
.chat-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  font-weight: bold;
  flex-shrink: 0;
  margin-right: 12px;
}

/* Само сообщение теперь в flex с аватаркой */
.chat-message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
  animation: slideIn 0.3s ease-out;
}

.chat-message-content {
  flex: 1;
  min-width: 0; /* для правильного переноса текста */
}

/* Модальное окно для смены имени */
.name-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.name-modal {
  background: white;
  border-radius: 16px;
  padding: 24px;
  width: 320px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: fadeIn 0.2s ease-out;
}

.name-modal h3 {
  margin-bottom: 16px;
  color: #333;
  text-align: center;
}

.name-modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1em;
  margin-bottom: 20px;
}

.name-modal-input:focus {
  outline: none;
  border-color: #667eea;
}

.name-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.name-modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.name-modal-btn-cancel {
  background: #f0f0f0;
  color: #666;
}

.name-modal-btn-save {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

#identifyButton {
    padding: 14px 32px;
    font-size: 1.1em;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: default;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

#identifyButton:not(:disabled) {
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer;
}

#identifyButton:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}