:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --user-bg: #1f2937;
  --assistant-bg: #161b22;
  --thinking-bg: #1e3a5f;
  --tool-bg: #1f1f1f;
  --success: #10b981;
  --error: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Loading State */
.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error State */
.error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.error-icon {
  font-size: 3rem;
}

.error h2 {
  color: var(--error);
}

.error p {
  color: var(--text-secondary);
  max-width: 400px;
}

.error a {
  color: var(--accent);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  transition: all 0.2s;
}

.error a:hover {
  background: var(--accent);
  color: white;
}

/* Password Form */
.password-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
}

.lock-icon {
  font-size: 3rem;
}

.password-form h2 {
  font-size: 1.5rem;
}

.password-form p {
  color: var(--text-secondary);
}

.password-form input {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  width: 100%;
  max-width: 300px;
}

.password-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.password-form button {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.password-form button:hover {
  background: var(--accent-hover);
}

.error-text {
  color: var(--error);
  font-size: 0.875rem;
}

/* Viewer */
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.viewer-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.header-content {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.header-content h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.meta {
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.message {
  display: flex;
  gap: 1rem;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.875rem;
}

.message.user .message-avatar {
  background: var(--user-bg);
}

.message.assistant .message-avatar {
  background: var(--accent);
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.6;
}

.message.user .message-bubble {
  background: var(--user-bg);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--assistant-bg);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

/* Thinking */
.thinking {
  background: var(--thinking-bg);
  border-left: 3px solid #60a5fa;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.thinking-header {
  font-weight: 500;
  color: #60a5fa;
  margin-bottom: 0.5rem;
}

/* Tool Call */
.tool-call {
  background: var(--tool-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.tool-name {
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.tool-input {
  background: var(--bg-primary);
  border-radius: 4px;
  padding: 0.5rem;
  overflow-x: auto;
}

.tool-input pre {
  margin: 0;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
  font-size: 0.75rem;
}

/* Code Blocks */
.message-bubble pre {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.message-bubble code {
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
  font-size: 0.875rem;
}

.message-bubble :not(pre) > code {
  background: var(--bg-primary);
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
}

/* Footer */
.viewer-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.import-info {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.import-info h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.import-info p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.import-info ol {
  margin-left: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.import-info li {
  margin-bottom: 0.25rem;
}

.import-info strong {
  color: var(--text-primary);
}

.branding {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.branding a {
  color: var(--text-secondary);
  text-decoration: none;
}

.branding a:hover {
  color: var(--accent);
}

/* Utility */
.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .viewer-header {
    padding: 1rem;
  }

  .messages {
    padding: 1rem;
  }

  .viewer-footer {
    padding: 1rem;
  }
}
