:root {
  --bg: #fafafa;
  --bg-editor: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e5e5e5;
  --accent: #0066cc;
  --accent-hover: #0052a3;
  --success: #22863a;
  --warning: #b08800;
}

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

body {
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-editor);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}

.logo svg {
  width: 24px;
  height: 24px;
}

.doc-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-id {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 6px 10px;
  border-radius: 4px;
}

.btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s ease;
}

.status-dot.connecting {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.status-dot.connected {
  background: var(--success);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Main content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Editor */
.editor-wrapper {
  flex: 1;
  background: var(--bg-editor);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.toolbar-btn:hover {
  background: var(--border);
  color: var(--text);
}

.toolbar-btn.active {
  background: var(--accent);
  color: white;
}

.toolbar-divider {
  width: 1px;
  background: var(--border);
  margin: 4px 8px;
}

.editor-content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

.editor-content:focus {
  outline: none;
}

/* Editor content styling */
.editor-content h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 16px;
  line-height: 1.3;
}

.editor-content h2 {
  font-size: 22px;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 12px;
  line-height: 1.3;
}

.editor-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
}

.editor-content p {
  margin-bottom: 12px;
  line-height: 1.6;
}

.editor-content ul, .editor-content ol {
  margin-bottom: 12px;
  padding-left: 24px;
}

.editor-content li {
  margin-bottom: 4px;
  line-height: 1.6;
}

.editor-content code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
}

.editor-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.editor-content pre code {
  background: transparent;
  padding: 0;
}

.editor-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.editor-content [data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: #aaa;
  pointer-events: none;
}

/* Footer */
.footer {
  padding: 16px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Loading state */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Peers indicator */
.peers-avatars {
  display: flex;
  margin-left: 8px;
}

.peer-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--bg-editor);
  margin-left: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
}

.peer-avatar:first-child {
  margin-left: 0;
}

/* Mobile */
@media (max-width: 640px) {
  .header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .main {
    padding: 16px;
  }

  .editor-content {
    padding: 16px;
  }

  .doc-id {
    font-size: 11px;
  }
}
