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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #fff;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 24px 20px 16px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 18px;
}

.header-btn {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: #2a2a4a;
  border: none;
  color: #888;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  flex-shrink: 0;
}

.header-btn:hover {
  background: #3a3a5a;
  color: #fff;
}

/* Help modal */
.help-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.help-modal-content {
  background: #16213e;
  border-radius: 14px;
  padding: 24px 20px;
  max-width: 340px;
  min-height: 260px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.help-pages {
  flex: 1;
}

.help-page p {
  color: #ccc;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 10px;
  text-align: left;
}

.help-page p b {
  color: #fff;
}

.help-page .help-title {
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 14px;
}

.help-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 12px 0;
}

.help-arrow {
  width: 32px;
  height: 32px;
  border-radius: 16px;
  background: #2a2a4a;
  border: none;
  color: #aaa;
  font-size: 16px;
  cursor: pointer;
}

.help-arrow:hover {
  background: #3a3a5a;
  color: #fff;
}

.help-arrow:disabled {
  opacity: 0.2;
  cursor: default;
}

.help-dots {
  display: flex;
  gap: 6px;
}

.help-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: #2a2a4a;
}

.help-dot.active {
  background: #2ecc71;
}

.help-close {
  background: #2ecc71;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 32px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.help-close:hover {
  background: #27ae60;
}

/* Settings modal */
.settings-modal-content {
  min-height: auto;
  background: #1a1a2e;
}

.settings-section {
  margin-bottom: 16px;
}

.settings-label {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  text-align: left;
}

.settings-hint {
  color: #666;
  font-size: 11px;
  margin-bottom: 10px;
  text-align: left;
}

.link-btn-half {
  padding: 10px 12px;
  font-size: 13px;
  flex-shrink: 0;
}

button.invite-color {
  background: transparent;
  color: #3498db;
  border: 1px solid #3498db;
}

button.invite-color:not(:disabled):hover {
  background: #3498db;
  color: #fff;
}

.settings-name-input {
  letter-spacing: normal;
  text-transform: none;
  font-weight: normal;
  font-size: 14px;
  text-align: left;
}

.invite-direction-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.invite-dir-btn {
  flex: 1;
  padding: 7px 4px;
  border-radius: 8px;
  border: 1px solid #3a3a5a;
  background: transparent;
  color: #888;
  cursor: pointer;
  font-size: 12px;
  text-align: center;
}

.invite-dir-btn.active {
  border-color: #2ecc71;
  color: #2ecc71;
  background: rgba(46, 204, 113, 0.1);
}

.invite-dir-btn:hover {
  border-color: #2ecc71;
}

.invite-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.invite-code {
  flex: 1;
  background: #16213e;
  color: #2ecc71;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  text-align: center;
  padding: 10px 8px;
  border-radius: 8px;
  user-select: all;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invite-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #2a2a4a;
  border: none;
  color: #aaa;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.invite-icon-btn:hover {
  background: #3a3a5a;
  color: #fff;
}

.invite-hint {
  color: #888;
  font-size: 12px;
  text-align: center;
  margin-bottom: 4px;
}

.invite-timer {
  color: #666;
  font-size: 11px;
}

.title-group {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0;
}

.title {
  font-size: 24px;
  font-weight: bold;
}

.title-at {
  color: #444;
  font-size: 18px;
  margin: 0 1px;
}

.device-name-label {
  color: #888;
  font-size: 15px;
  font-weight: 500;
}

/* Status */
.status-badge {
  align-self: center;
  padding: 4px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.status-badge.connected {
  background: #2ecc71;
}

.status-badge.disconnected {
  background: #e74c3c;
}

.error-text {
  color: #e74c3c;
  font-size: 12px;
  text-align: center;
  margin-bottom: 8px;
}

/* Chat list */
.chat-list-container {
  flex: 1;
  overflow-y: auto;
  margin: 10px 0;
}

.empty-text {
  color: #666;
  font-size: 13px;
  text-align: center;
  margin-top: 40px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-row {
  display: flex;
  align-items: center;
  background: #16213e;
  border-radius: 12px;
  padding: 10px 14px;
}

.bell-icon {
  font-size: 20px;
  opacity: 0.3;
  margin-right: 12px;
  flex-shrink: 0;
}

.bell-icon.golden {
  opacity: 1;
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  color: #666;
  font-size: 11px;
  margin-top: 2px;
}

.chat-message-preview {
  color: #8899aa;
  font-size: 12px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-height: 1.4em;
  cursor: pointer;
  line-height: 1.4;
}

.chat-message-preview:hover {
  color: #aabbcc;
}

.chat-message-expanded {
  white-space: normal;
  max-height: none;
  word-break: break-word;
}

.chat-message-from {
  color: #2ecc71;
  font-weight: 600;
}

.ring-btn {
  width: 32px;
  height: 32px;
  border-radius: 16px;
  background: #2ecc71;
  border: none;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 6px;
}

.ring-btn:hover {
  background: #27ae60;
}

.ring-btn:active {
  transform: scale(0.9);
}

.unlink-btn {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: #2a2a4a;
  border: none;
  color: #e74c3c;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
}

.unlink-btn:hover {
  background: #3a3a5a;
}

/* Link row */
.link-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.link-input {
  flex: 1;
  min-width: 0;
  background: #16213e;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  border: none;
  border-radius: 12px;
  padding: 10px 10px;
  outline: none;
}

.link-input::placeholder {
  color: #666;
  letter-spacing: normal;
  font-weight: normal;
}

.link-input:disabled {
  opacity: 0.5;
}

.link-btn {
  background: #2ecc71;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  padding: 10px 22px;
  cursor: pointer;
}

.link-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.link-btn:not(:disabled):hover {
  background: #27ae60;
}

.link-hint {
  color: #666;
  font-size: 11px;
  text-align: center;
  margin-bottom: 12px;
}

/* Recovery */
.recover-section {
  margin-bottom: 12px;
}

.recover-label {
  color: #666;
  font-size: 11px;
  text-align: center;
  margin-bottom: 6px;
}

.recover-btn {
  background: #e67e22;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  padding: 10px 22px;
  cursor: pointer;
  flex-shrink: 0;
}

.recover-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.recover-btn:not(:disabled):hover {
  background: #d35400;
}

/* Footer */
.server-footer {
  color: #444;
  font-size: 11px;
  text-align: center;
}

/* Scrollbar */
.chat-list-container::-webkit-scrollbar {
  width: 4px;
}

.chat-list-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list-container::-webkit-scrollbar-thumb {
  background: #2a2a4a;
  border-radius: 2px;
}
