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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #242833;
  --border: #2a2e3a;
  --text: #e4e4e7;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --user-bg: #1e3a5f;
  --ai-bg: #1a1d27;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0 1rem;
}

header {
  padding: 1.5rem 0 0.5rem;
  text-align: center;
  flex-shrink: 0;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.125rem;
}

.tagline {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.description {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 600px;
  margin: 0 auto;
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.starters {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding-top: 2rem;
}

.starters h2 {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.starter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  max-width: 600px;
}

.starter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}

.starter-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.message-role {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.message-content {
  padding: 1rem;
  border-radius: 0.75rem;
  line-height: 1.6;
  font-size: 0.9375rem;
}

.message.user .message-content {
  background: var(--user-bg);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.message.assistant .message-content {
  background: var(--surface);
  border: 1px solid var(--border);
}

.message-content p {
  margin-bottom: 0.75rem;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  color: var(--accent);
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 1rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.input-area {
  padding: 1rem 0 1.5rem;
  flex-shrink: 0;
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.5rem;
}

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.9375rem;
  padding: 0.5rem;
  outline: none;
}

#user-input::placeholder {
  color: var(--text-muted);
}

#send-btn {
  background: var(--accent);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#send-btn:hover {
  background: var(--accent-hover);
}

#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.jd-panel {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
}

.jd-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8125rem;
  user-select: none;
}

.jd-header svg {
  flex-shrink: 0;
}

#jd-status-text {
  flex: 1;
}

.jd-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  transition: transform 0.2s;
}

.jd-panel.collapsed .jd-toggle {
  transform: rotate(-90deg);
}

.jd-panel.collapsed .jd-body {
  display: none;
}

.jd-body {
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.jd-input-tabs {
  display: flex;
  gap: 0.25rem;
}

.jd-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s;
}

.jd-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.jd-tab-content.hidden {
  display: none;
}

#jd-text {
  width: 100%;
  min-height: 100px;
  max-height: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 0.75rem;
  resize: vertical;
  outline: none;
}

#jd-text:focus {
  border-color: var(--accent);
}

#jd-url {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 0.8125rem;
  padding: 0.75rem;
  outline: none;
}

#jd-url:focus {
  border-color: var(--accent);
}

#jd-url::placeholder,
#jd-text::placeholder {
  color: var(--text-muted);
}

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

.jd-apply-btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s;
}

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

.jd-apply-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.jd-clear-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s;
}

.jd-clear-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.jd-clear-btn.hidden {
  display: none;
}

.jd-active-badge {
  display: inline-block;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-weight: 500;
}

@media (max-width: 640px) {
  .container { padding: 0 0.75rem; }
  header { padding: 1.5rem 0 0.75rem; }
  header h1 { font-size: 1.5rem; }
  .starter-grid { flex-direction: column; }
  .footer-links { flex-direction: column; }
}

footer {
  flex-shrink: 0;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: color 0.15s;
}

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