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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #e5e5e5;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 600px;
  height: 100vh;
  max-height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.chat-header {
  background: #3390ec;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-header .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
}

.chat-header .info {
  flex: 1;
}

.chat-header .info .name {
  font-weight: 600;
  font-size: 15px;
}

.chat-header .info .status {
  font-size: 12px;
  opacity: 0.85;
}

.chat-header .info .status.connected {
  color: #d4f7d4;
}

.chat-header .info .status.disconnected {
  color: #f7d4d4;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #8ba0b5
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%237a93a8' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.message {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
}

.message.user {
  align-self: flex-end;
  background: #effdde;
  border-bottom-right-radius: 4px;
}

.message.bot {
  align-self: flex-start;
  background: #fff;
  border-bottom-left-radius: 4px;
}

.message .text {
  white-space: pre-wrap;
}

.message .html-text {
  white-space: normal;
}

.message .html-text b,
.message .html-text strong {
  font-weight: 700;
}

.message .html-text i,
.message .html-text em {
  font-style: italic;
}

.message .html-text u {
  text-decoration: underline;
}

.message .html-text s,
.message .html-text del {
  text-decoration: line-through;
}

.message .html-text code {
  background: #f0f0f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  word-break: break-word;
}

.message .html-text pre {
  background: #f4f4f4;
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.message .html-text pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.message .html-text a {
  color: #3390ec;
  text-decoration: none;
}

.message .html-text a:hover {
  text-decoration: underline;
}

.message .html-text blockquote {
  border-left: 3px solid #3390ec;
  padding-left: 10px;
  margin: 6px 0;
  color: #555;
}

.message .html-text .tg-spoiler {
  background: #555;
  color: transparent;
  border-radius: 3px;
  padding: 0 2px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.message .html-text .tg-spoiler:hover,
.message .html-text .tg-spoiler.revealed {
  background: transparent;
  color: inherit;
}

.message .html-text p {
  margin: 4px 0;
}

.message.command .text {
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.message .meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.message .meta .time {
  font-size: 11px;
  color: #999;
}

.inline-keyboard {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.keyboard-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.keyboard-btn {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid #3390ec;
  border-radius: 6px;
  background: #fff;
  color: #3390ec;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  box-sizing: border-box;
}

.keyboard-btn:hover {
  background: #f0f7ff;
}

.keyboard-btn.clicked {
  background: #3390ec;
  color: #fff;
}

.keyboard-btn.url-btn {
  border-color: #888;
  color: #555;
}

.keyboard-btn.url-btn:hover {
  background: #f5f5f5;
}

.keyboard-btn .url-icon {
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.7;
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.chat-input {
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  gap: 8px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
  position: relative;
}

.menu-wrapper {
  position: relative;
  flex-shrink: 0;
}

.menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #f0f0f0;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.menu-btn:hover {
  background: #e0e0e0;
  color: #333;
}

.menu-btn.active {
  background: #3390ec;
  color: #fff;
}

.menu-btn.active:hover {
  background: #2b7fd4;
}

.menu-btn svg {
  width: 20px;
  height: 20px;
}

.menu-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 100;
  min-width: 180px;
}

.menu-slide-enter-active,
.menu-slide-leave-active {
  transition: all 0.2s ease;
}

.menu-slide-enter-from,
.menu-slide-leave-to {
  opacity: 0;
  transform: translateY(8px);
}

.menu-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: #333;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.menu-item:hover {
  background: #f0f7ff;
  color: #3390ec;
}

.menu-item + .menu-item {
  border-top: 1px solid #f0f0f0;
}

.chat-input textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  padding: 8px 0;
  background: transparent;
}

.chat-input textarea::placeholder {
  color: #aaa;
}

.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #3390ec;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.send-btn:hover {
  background: #2b7fd4;
}

.send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

.logout-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.logout-btn:hover {
  color: #fff;
}

.logout-btn svg {
  width: 20px;
  height: 20px;
}

.test-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.test-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.login-screen {
  width: 100%;
  max-width: 600px;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.login-card {
  text-align: center;
  padding: 40px;
  width: 100%;
  max-width: 320px;
}

.login-icon {
  margin-bottom: 20px;
  color: #3390ec;
}

.login-icon svg {
  width: 48px;
  height: 48px;
}

.login-card h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #333;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form input {
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.login-form input:focus {
  border-color: #3390ec;
}

.login-btn {
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #3390ec;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover {
  background: #2b7fd4;
}

.login-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.login-error {
  color: #e74c3c;
  font-size: 13px;
}

@media (max-width: 600px) {
  #app {
    max-width: 100%;
    box-shadow: none;
  }
}
