
:root {
  --bg-main: #09090b;
  --bg-card: #18181b;
  --bg-card-hover: #27272a;
  --border: #27272a;
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --primary: #10a37f;
  --primary-hover: #0d8a6b;
  --danger: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.header {
  height: 56px;
  background-color: rgba(24, 24, 27, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active {
  background-color: var(--bg-card-hover);
}

.project-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #27272a;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chat container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 72px 16px 140px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-screen {
  margin: auto;
  max-width: 480px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
}
.welcome-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #10a37f, #065f46);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(16, 163, 127, 0.3);
}
.welcome-title {
  font-size: 20px;
  font-weight: 600;
}
.welcome-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}
.suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
}
.suggestion-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s;
}
.suggestion-card:active {
  border-color: var(--primary);
  background-color: var(--bg-card-hover);
}

/* Message items */
.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}
.message.user {
  align-self: flex-end;
  max-width: 85%;
}
.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.message.user .message-bubble {
  background-color: #27272a;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.message.assistant .message-bubble {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

/* Tool execution details */
.tool-box {
  margin-top: 8px;
  background-color: #0c0c0e;
  border: 1px solid #27272a;
  border-radius: 8px;
  font-size: 12px;
  overflow: hidden;
}
.tool-header {
  padding: 8px 12px;
  background-color: #1f1f23;
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.tool-content {
  padding: 10px 12px;
  max-height: 200px;
  overflow-y: auto;
  font-family: monospace;
  white-space: pre-wrap;
  color: #d4d4d8;
  border-top: 1px solid #27272a;
}

/* Markdown styling inside assistant message */
.markdown-body pre {
  background-color: #09090b;
  border: 1px solid #27272a;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
}
.markdown-body code {
  background-color: #27272a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.markdown-body p {
  margin-bottom: 8px;
}
.markdown-body p:last-child {
  margin-bottom: 0;
}
.markdown-body ul, .markdown-body ol {
  padding-left: 20px;
  margin: 8px 0;
}

.msg-actions {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 8px;
}
.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.msg-action-btn:active {
  color: var(--text-main);
}

/* Input Area */
.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
}
.quick-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 4px;
  scrollbar-width: none;
}
.quick-chips::-webkit-scrollbar {
  display: none;
}
.chip {
  flex-shrink: 0;
  background-color: #27272a;
  border: 1px solid #3f3f46;
  color: #d4d4d8;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
}
.chip:active {
  background-color: var(--primary);
  color: #fff;
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background-color: #09090b;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  transition: border-color 0.2s;
}
.input-wrapper:focus-within {
  border-color: var(--primary);
}
.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.4;
  max-height: 120px;
  min-height: 24px;
  outline: none;
  resize: none;
  padding: 4px 0;
}
.send-btn {
  background-color: var(--primary);
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s, background-color 0.2s;
}
.send-btn.stop {
  background-color: var(--danger);
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Sidebar Drawer */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 280px;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border);
  z-index: 51;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}
.sidebar.active {
  transform: translateX(0);
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.session-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.session-item:active, .session-item.active {
  background-color: #27272a;
}
.session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-main);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.menu-btn:active {
  background-color: #27272a;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 13px;
  color: var(--text-muted);
}
.form-input, .form-select {
  background-color: #09090b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--primary);
}
.btn-primary {
  background-color: var(--primary);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}
.btn-primary:active {
  background-color: var(--primary-hover);
}
.btn-secondary {
  background-color: #27272a;
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

/* Install PWA Prompt Banner */
.pwa-banner {
  background: linear-gradient(90deg, #065f46, #10a37f);
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 39;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.pwa-banner button {
  background: white;
  color: #065f46;
  border: none;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}
