* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid #2a2a2a;
  margin-bottom: 16px;
}

h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: #ffffff;
}

.status {
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 500;
}

.status.connected { background: #1a3a1a; color: #4caf50; }
.status.disconnected { background: #3a1a1a; color: #f44336; }
.status.pairing { background: #3a351a; color: #ffc107; }
.status.paired { background: #1a2a3a; color: #2196f3; }

#identity-section {
  margin-bottom: 16px;
}

#hash-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a1a1a;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #333;
}

#hash-display label {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}

#hash-value {
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #4fc3f7;
  flex: 1;
}

#controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}

.btn.primary {
  background: #1976d2;
  color: white;
}

.btn.primary:hover { background: #1565c0; }
.btn.primary:disabled { background: #333; color: #666; cursor: not-allowed; }

.btn.secondary {
  background: #424242;
  color: #ccc;
}

.btn.secondary:hover { background: #535353; }

.btn-small {
  padding: 4px 10px;
  border: 1px solid #555;
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-small:hover { background: #2a2a2a; color: #e0e0e0; }

.btn-small.danger { border-color: #5c2a2a; color: #f44336; }
.btn-small.danger:hover { background: #3a1a1a; color: #ff5252; }

.hidden { display: none !important; }

#pairing-section {
  margin-bottom: 16px;
}

.input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.9rem;
}

input[type="text"]:focus {
  outline: none;
  border-color: #1976d2;
}

#message-input {
  flex: 1;
  padding: 10px 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  overflow-y: auto;
  min-height: 20px;
  max-height: 200px;
}

#message-input:focus {
  outline: none;
  border-color: #1976d2;
}

#pair-notification-area {
  background: #1a1a1a;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #333;
}

#pair-notification-text {
  margin-bottom: 12px;
}

#pin-accept-area p {
  margin-bottom: 8px;
}

#chat-section {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #1a1a1a;
  border-radius: 8px 8px 0 0;
  border: 1px solid #333;
  border-bottom: none;
  font-size: 0.85rem;
}

.enc-pending { color: #ffc107; }
.enc-active { color: #4caf50; }

.messages {
  height: 300px;
  overflow-y: auto;
  background: #111;
  border: 1px solid #333;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 80%;
  word-wrap: break-word;
}

.message.sent {
  background: #1a3a5c;
  align-self: flex-end;
}

.message.received {
  background: #2a2a2a;
  align-self: flex-start;
}

.message.system {
  background: transparent;
  align-self: center;
  font-size: 0.8rem;
  color: #666;
}

.message .msg-text {
  font-size: 0.9rem;
  line-height: 1.4;
}

.message .msg-time {
  font-size: 0.7rem;
  color: #888;
  margin-top: 4px;
}

#message-input-area {
  border: 1px solid #333;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 8px;
  background: #1a1a1a;
}

#message-input-area .input-row {
  margin-top: 0;
}

.error {
  background: #3a1a1a;
  color: #f44336;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid #5c2a2a;
  font-size: 0.9rem;
}

#error-section {
  position: fixed;
  top: 16px;
  right: 16px;
  max-width: 360px;
  z-index: 100;
}

/* --- File entity --- */

.message.file-entity {
  background: #1a2a1a;
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
  border: 1px solid #2a4a2a;
}

.message.file-entity.sent {
  background: #1a2a3a;
  border-color: #2a3a5a;
}

.file-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.file-icon { font-size: 1.2rem; }

.file-name {
  font-weight: 600;
  color: #e0e0e0;
  word-break: break-all;
}

.file-meta {
  font-size: 0.75rem;
  color: #888;
}

.file-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.file-progress-row progress {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  border: none;
  background: #333;
  color: #1976d2;
}

.file-progress-row progress::-webkit-progress-bar {
  background: #333;
  border-radius: 3px;
}

.file-progress-row progress::-webkit-progress-value {
  background: #1976d2;
  border-radius: 3px;
}

.file-progress-text {
  font-size: 0.75rem;
  color: #888;
  min-width: 36px;
  text-align: right;
}

.file-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}

.file-received-badge {
  color: #4caf50;
  font-size: 0.8rem;
  font-weight: 500;
}

#btn-file {
  font-size: 1.1rem;
  padding: 10px 12px;
  line-height: 1;
}

.messages.drag-over {
  border-color: #1976d2;
  background: #1a2a3a;
}
