*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.app-root {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  color: inherit;
}

.sidebar {
  width: 260px;
  padding: 16px 14px;
  border-right: 1px solid rgba(148, 163, 184, 0.4);
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 16px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-btn {
  border-radius: 10px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: #4b5563;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-btn:hover {
  background: rgba(229, 231, 235, 0.9);
}

.nav-btn.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: #9ca3af;
}

.main {
  flex: 1;
  padding: 18px 22px;
  display: flex;
  height: 100vh;
  box-sizing: border-box;
  overflow: hidden;
}

.panel {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #ffffff;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.panel-split {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
}

.panel-left,
.panel-right {
  padding: 18px 18px 16px;
}

.panel-left {
  border-right: 1px solid rgba(148, 163, 184, 0.25);
}

.panel-header h1 {
  margin: 0;
  font-size: 20px;
}

.panel-header .muted {
  margin-top: 4px;
}

.muted {
  color: #6b7280;
  font-size: 13px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row-2col,
.form-row-3col {
  display: grid;
  gap: 10px;
}

.form-row-2col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-row-3col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label {
  font-size: 12px;
  color: #6b7280;
}

.input {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #f9fafb;
  padding: 7px 9px;
  font-size: 13px;
  color: #111827;
  outline: none;
}

.input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
}

.textarea {
  min-height: 70px;
  resize: vertical;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.secondary-btn {
  background: #ffffff;
  color: #111827;
  border: 1px solid rgba(148, 163, 184, 0.8);
}

.danger-btn {
  background: rgba(239, 68, 68, 0.07);
  color: #b91c1c;
  border: 1px solid rgba(248, 113, 113, 0.8);
}

.error-text {
  color: #f97373;
  font-size: 13px;
}

.pill {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 2px 10px;
  font-size: 11px;
  color: #374151;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
}

.pill-soft {
  border-color: transparent;
  background: rgba(59, 130, 246, 0.12);
}

.models-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  margin-bottom: 4px;
}

.agents-list {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.agent-item {
  border-radius: 10px;
  border: none;
  background: transparent;
  padding: 8px 9px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.agent-item:hover {
  background: rgba(229, 231, 235, 0.8);
}

.agent-item.active {
  background: rgba(59, 130, 246, 0.08);
}

.agent-name {
  font-size: 14px;
}

.agent-meta {
  font-size: 11px;
  color: #9ca3af;
}

.empty-state {
  padding: 30px 8px;
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.conversations-list-wrapper {
  margin-top: 10px;
  border-radius: 12px;
  background: #f9fafb;
  padding: 8px 6px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}

.list-header-small {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 6px;
  padding: 0 4px;
}

.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-item {
  border-radius: 10px;
  border: none;
  background: transparent;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conversation-item:hover {
  background: rgba(229, 231, 235, 0.9);
}

.conversation-item.active {
  background: #eef2ff;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
}

.conversation-title {
  font-size: 13px;
  color: #111827;
}

.conversation-preview {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.chat-messages {
  margin-top: 10px;
  padding-right: 4px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  padding: 8px 10px;
  border-radius: 14px;
  max-width: 80%;
  white-space: normal;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #f9fafb;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: #ffffff;
}

.chat-role {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 3px;
}

.chat-content {
  font-size: 13px;
}

.chat-debug {
  margin-top: 4px;
  font-size: 11px;
}

.chat-debug summary {
  cursor: pointer;
  color: #6b7280;
}

.chat-input-bar {
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input-bar .textarea {
  flex: 1;
  resize: none;
}

.chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-main-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conversation-id {
  font-size: 11px;
  color: #9ca3af;
}

.empty-state.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.markdown-body {
  font-size: 12px;
  line-height: 1.6;
}

.chat-bubble.assistant .markdown-body {
  font-size: 12px;
}

.markdown-body p {
  margin: 0 0 4px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 18px;
  margin: 4px 0;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #f3f4f6;
}

.markdown-body pre {
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #020617;
  color: #e5e7eb;
  overflow-x: auto;
  font-size: 12px;
}

.code-block {
  background: #020617;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.9);
  padding: 8px 10px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #e5e7eb;
}

.panel-section h2 {
  margin: 12px 0 4px;
  font-size: 14px;
}

.section-toggle {
  margin-top: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}

.section-toggle:hover {
  background: #eef2ff;
  border-color: #6366f1;
}

.section-toggle-icon {
  font-size: 12px;
  color: #9ca3af;
}

/* ===== Variables & Mentions ===== */

.small {
  font-size: 12px;
}

.variable-hints {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.variable-hints .label {
  margin-right: 4px;
}

.variable-preview {
  margin-top: 6px;
}

.variable-preview-box {
  margin-top: 2px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px dashed rgba(148, 163, 184, 0.7);
  font-size: 12px;
  color: #374151;
  white-space: pre-wrap;
}

.variable-preview-box.small {
  font-size: 12px;
}

.variables-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.variable-item {
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  padding: 10px 10px 8px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.variable-item .form-grid {
  gap: 8px;
}

.variable-item .textarea {
  min-height: 60px;
}

.chat-input-main {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mention-menu {
  position: absolute;
  left: 0;
  bottom: 44px;
  min-width: 220px;
  max-height: 180px;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  padding: 4px;
  z-index: 10;
}

.mention-item {
  width: 100%;
  padding: 4px 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  cursor: pointer;
  font-size: 12px;
  color: #111827;
}

.mention-item:hover {
  background: #eef2ff;
}

.mention-name {
  font-weight: 500;
}

.mention-preview-text {
  font-size: 11px;
  color: #6b7280;
}

.mention-used {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
}

.mention-used .label {
  margin-right: 2px;
}

.mention-used-value {
  margin-left: 4px;
  font-size: 11px;
  color: #4b5563;
}

@media (max-width: 960px) {
  .sidebar {
    display: none;
  }

  .main {
    padding: 10px;
  }

  .panel-split {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  }
}

