body {
  margin: 0;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f0f0;
  color: #333;
  max-width: 800px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
}

#chat-name {
  margin: 0;
  font-size: 1.8em;
  color: #222;
  font-weight: 300;
  word-break: break-word;
  flex: 1 1 100%;
}

.token-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  position: relative;
}

#token-display {
  font-family: monospace;
  background: #eee;
  padding: 4px 8px;
  border-radius: 4px;
}

#token-input {
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 120px;
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.copy-icon {
  width: 18px;
  height: 18px;
  fill: #666;
}

.copy-btn:hover .copy-icon {
  fill: #333;
}

#refresh-user {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.refresh-icon {
  width: 20px;
  height: 20px;
  fill: #666;
}

#refresh-user:hover .refresh-icon {
  fill: #333;
}

#random-chat {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.dice-icon {
  width: 20px;
  height: 20px;
  fill: #666;
}

#random-chat:hover .dice-icon {
  fill: #4CAF50;
}

#messages {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message {
  margin-bottom: 15px;
  padding: 12px;
  background: #fff;
  border-radius: 4px;
  border: 1px solid #eee;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.message:first-child {
  margin-top: 0;
}

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

.user {
  font-weight: bold;
}

.timestamp {
  font-size: 0.85em;
}

.content {
  line-height: 1.4;
}

.save-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-left: 10px;
}

.save-icon {
  width: 18px;
  height: 18px;
  fill: #666;
  transition: fill 0.2s;
}

.save-btn:hover .save-icon {
  fill: #4CAF50;
}

#message-form {
  display: flex;
  gap: 10px;
}

#message-input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  min-height: 80px;
}

button[type="submit"] {
  padding: 10px 20px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button[type="submit"]:hover {
  background: #45a049;
}

.form-row {
  margin-bottom: 10px;
}

.upload-btn {
  background: #4CAF50;
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-block;
  border: none;
}

.upload-btn:hover {
  background: #45a049;
}

.image-preview {
  margin-top: 10px;
  display: none;
}

.image-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 4px;
}

.message-image {
  max-width: 100%;
  max-height: 300px;
  margin-top: 15px;
  border-radius: 4px;
  border: 1px solid #eee;
  padding: 5px;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
}

.nav-icon {
  width: 28px;
  height: 28px;
  fill: #666;
}

.tab-content {
  position: relative;
  min-height: 60vh;
}

.chat-tab, .saved-tab {
  position: absolute;
  width: 100%;
  transition: transform 0.3s ease;
}

.saved-tab {
  transform: translateX(100%);
}

.saved-tab.active {
  transform: translateX(0);
}

.saved-message {
  background: #f8f8f8;
  margin-bottom: 15px;
  padding: 15px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.saved-message:hover {
  transform: translateX(5px);
}

.saved-message .meta {
  font-size: 0.8em;
  color: #666;
  margin-bottom: 5px;
}

.profile-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  margin: 20px auto;
  display: block;
}

.profile-icon {
  width: 40px;
  height: 40px;
  fill: #666;
  transition: fill 0.2s;
}

.profile-btn:hover .profile-icon {
  fill: #4CAF50;
}

.profile-login {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hidden {
  display: none;
}

.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
  z-index: 1000;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 999;
}

.profile-login input {
  margin: 5px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.profile-login button {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
}

.empty {
  text-align: center;
  color: #666;
  padding: 20px;
}