:root {
  --bg-info: #1b2028;
  --bg-dark: #0d1117;
  --bg-panel: #161b22;
  --bg-input: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --success: #3fb950;
  --danger: #f85149;
  --character-primary-text: #e6edf3;
  --character-brandprimary-text: #58a6ff;
  --container-secondary-bgweb: #111827;
  --container-quaternary-fill: rgba(255, 255, 255, 0.15);
  --line-secondary-border: #1f2937;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; background: #0b1220; color: #e5e7eb; }
.layout { display: grid; grid-template-columns: 260px 1fr; grid-template-rows: 1fr; height: 100vh; overflow: hidden; }
.link {
  display: inline-block; 
  color: #60a5fa;
  text-decoration: none;
  font-size: 0.95rem;
}
.sidebar {
  width: 260px;
  max-width: 260px;
  flex-shrink: 0;
  min-height: 0;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  transition: width .2s ease-in-out;
  overflow: hidden;
  font-size: 14px;
  line-height: 20px;
  color: var(--character-primary-text);
  background: var(--container-secondary-bgweb);
  border-right: 1px solid var(--line-secondary-border);
  display: flex;
  flex-direction: column;
  padding: 12px;
}
.sidebar-projects {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar-projects::-webkit-scrollbar { display: none; }
.active-task-block { flex-shrink: 0; margin-bottom: 14px; padding: 12px; background: rgba(59, 130, 246, 0.12); border: 1px solid rgba(59, 130, 246, 0.3); border-radius: 10px; cursor: pointer; }
.active-task-block:hover { background: rgba(59, 130, 246, 0.18); }
.active-task-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: #93c5fd; margin-bottom: 6px; }
.active-task-project { font-size: 14px; font-weight: 600; color: #e5e7eb; margin-bottom: 4px; }
.active-task-status { font-size: 12px; color: #93c5fd; margin-bottom: 8px; }
.active-task-actions { display: flex; gap: 8px; }
.active-task-block .btn-active-task-open { padding: 6px 12px; background: #2563eb; color: #fff; border: 0; border-radius: 6px; cursor: pointer; font-size: 12px; }
.active-task-block .btn-active-task-cancel { padding: 6px 12px; background: transparent; color: #f87171; border: 1px solid #f87171; border-radius: 6px; cursor: pointer; font-size: 12px; }
.sidebar-head { flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sidebar h2 { margin: 0; font-size: 16px; }
#new-project-btn, .dialog-actions button { background: #2563eb; color: #fff; border: 0; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.chat-tools-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-tools-row { 
  display: flex;
  align-items: center;
  /* justify-content: space-between; */
  gap: 8px;
  /* width: 100%; */
}
#chat-send-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#chat-send-btn:hover:not(:disabled) { background: #3b82f6; }
#chat-send-btn:disabled { opacity: 0.6; cursor: not-allowed; }
#chat-send-btn.cancel { background: #dc2626; }
#chat-send-btn.cancel:hover:not(:disabled) { background: #ef4444; }
#project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#project-list li { background: #1f2937; padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#project-list li.active { outline: 1px solid #3b82f6; }
#project-list .project-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#project-list .project-item-menu { position: relative; flex-shrink: 0; }
#project-list .btn-project-menu { background: none; border: 0; color: #9ca3af; cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 16px; line-height: 1; }
#project-list .btn-project-menu:hover { color: #e5e7eb; background: rgba(255,255,255,0.08); }
.project-dropdown { min-width: 200px; background: #1f2937; border: 1px solid #374151; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); z-index: 1100; padding: 4px 0; list-style: none; margin: 0; }
#project-menu-dropdown { position: fixed; }
.project-dropdown li { background: none; padding: 0; border-radius: 0; outline: none; display: flex; cursor: pointer; }
.project-dropdown li a, .project-dropdown li button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 14px; background: none; border: 0; color: #e5e7eb; font-size: 13px; text-align: left; cursor: pointer; }
.project-dropdown li:hover { background: rgba(255,255,255,0.08); }
.project-dropdown li.project-dropdown-delete a, .project-dropdown li.project-dropdown-delete button { color: #f87171; }
.muted { color: #9ca3af; font-size: 13px; }
.main { display: flex; flex-direction: column; align-items: center; min-height: 0; overflow: hidden; }
.main-head { width: -webkit-fill-available; flex-shrink: 0; border-bottom: 1px solid #1f2937; padding: 12px; background: #111827; }
.main-head h1 { margin: 0 0 6px 0; font-size: 16px; }
.status-line { display: flex; gap: 10px; color: #93c5fd; font-size: 12px; min-height: 16px; }
.chat-box-wrapper { 
  display: flex;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  height: 100%;
  margin-bottom: 100px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  scroll-behavior: smooth;
}
.chat-box {
  flex: 1;
  padding: 12px;
  padding-bottom: 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 750px;
}
.chat-box-wrapper::-webkit-scrollbar { width: 6px; opacity: 0; -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease; }
.chat-box-wrapper::-webkit-scrollbar-track { background: transparent; }
.chat-box-wrapper::-webkit-scrollbar-thumb { background-color: var(--container-quaternary-fill); border-radius: 3px; opacity: 0; -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease; }
.chat-box-wrapper:hover::-webkit-scrollbar-thumb,
.chat-box-wrapper:active::-webkit-scrollbar-thumb { opacity: 1; }
.chat-box-wrapper:hover::-webkit-scrollbar,
.chat-box-wrapper:active::-webkit-scrollbar { opacity: 1; }
.chat-box-wrapper:hover { scrollbar-color: rgba(0, 0, 0, 0.2) transparent; }
.chat-empty-placeholder {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  gap: 8px;
  padding: 24px;
}
.chat-empty-placeholder.hidden { display: none !important; }
.chat-empty-placeholder .chat-empty-emoji { font-size: 48px; opacity: 0.8; }
.chat-empty-placeholder .chat-empty-text { margin: 0; font-size: 14px; line-height: 1.5; }
.project-chat-panel { display: flex; flex-direction: column; gap: 16px; min-height: min-content; flex-shrink: 0; }
.project-chat-panel[hidden] { display: none !important; }
.chat-message { padding: 12px; background: var(--bg-input); border-radius: 8px; border-left: 4px solid var(--accent); }
.chat-message.agent-2 { border-left-color: #58a6ff; }
.chat-message-user { border-left-color: #3fb950; }
.chat-message-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.chat-message .agent-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
.chat-message .agent-badge.agent-2 { background: rgba(88, 166, 255, 0.2); color: #58a6ff; }
.chat-message .agent-badge.agent-user { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.chat-message .tick-badge { font-size: 11px; color: var(--text-muted); }
.chat-widget { margin: 10px 0; border-radius: 6px; overflow: hidden; }
.chat-widget-text { padding: 10px; background: var(--bg-info); border-radius: 6px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; position: relative; }
.chat-user-msg-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; opacity: 0.5; transition: opacity 0.2s;
}
.chat-widget-text:hover .chat-user-msg-actions { opacity: 1; }
.chat-user-msg-action {
  width: 28px; height: 28px; padding: 0; border: none; background: transparent; border-radius: 6px;
  cursor: pointer; color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.chat-user-msg-action:hover { background: rgba(0,0,0,0.1); color: var(--text); }
.chat-user-msg-action-delete:hover { color: #f87171; background: rgba(248,113,113,0.1); }
.chat-user-msg-action svg { width: 14px; height: 14px; }
.chat-widget-code { padding: 12px; background: #0d1117; border: 1px solid var(--border); border-radius: 6px; font-family: Consolas, Monaco, monospace; font-size: 12px; max-height: 100px; overflow: auto; }
.chat-widget-code pre { margin: 0; }
.chat-widget-checklist { padding: 10px; }
.chat-widget-checklist-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.chat-widget-checklist-item.done { color: var(--text-muted); text-decoration: line-through; }
.chat-widget-analysis-block { padding: 10px 12px; background: rgba(88, 166, 255, 0.08); border: 1px solid rgba(88, 166, 255, 0.2); border-radius: 6px; }
.chat-widget-analysis-block .analysis-label { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.chat-widget-analysis-block .analysis-detail { font-size: 13px; margin-bottom: 4px; }
.chat-widget-analysis-block .analysis-snippets { font-size: 11px; color: var(--text-muted); }
.chat-widget-plan { padding: 10px 12px; background: rgba(63, 185, 80, 0.06); border: 1px solid rgba(63, 185, 80, 0.2); border-radius: 6px; }
.chat-widget-plan .plan-label { font-size: 12px; font-weight: 600; color: var(--success); margin-bottom: 6px; }
.chat-widget-plan .plan-list { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.5; }
.chat-widget-prepare { padding: 14px 16px; background: rgba(88, 166, 255, 0.08); border: 1px solid rgba(88, 166, 255, 0.25); border-radius: 8px; }
.chat-widget-prepare .prepare-title { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 10px; }
.chat-widget-prepare .plan-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.chat-widget-prepare .plan-list { margin: 0 0 10px 0; padding-left: 18px; font-size: 14px; line-height: 1.45; list-style: circle; }
.chat-widget-prepare .prepare-plan-editor { width: 100%; min-height: 100px; margin: 0 0 10px 0; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input); color: var(--text); font-size: 12px; }
.chat-widget-prepare .prepare-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.chat-widget-prepare .btn-create { margin-top: 8px; padding: 8px 14px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; cursor: pointer; }
.chat-widget-steps { padding: 10px 12px; background: var(--bg-dark); border-radius: 6px; }
.chat-widget-steps .steps-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.chat-widget-steps .steps-list { display: flex; flex-direction: column; gap: 4px; }
.chat-widget-steps .checklist-step { font-size: 12px; display: flex; align-items: center; gap: 6px; }
.chat-widget-steps .checklist-step .step-icon { color: var(--text-muted); width: 16px; }
.chat-widget-steps .checklist-step.done .step-icon { color: var(--success); }
.chat-widget-status { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12px; color: var(--text-muted); background: var(--bg-dark); border-radius: 6px; }
.chat-widget-status .status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: pulse 1.5s infinite; }
.chat-widget-status.done .status-dot { background: var(--success); animation: none; }
.chat-stream-output { margin-top: 10px; max-height: 120px; overflow-y: auto; background: var(--bg-dark); border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.chat-stream-output pre { margin: 0; font-family: Consolas, Monaco, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.chat-stream-status { font-size: 11px; color: var(--text-muted); }
.chat-message-header .btn-stream-cancel { margin-left: auto; padding: 4px 10px; font-size: 11px; background: transparent; color: #f87171; border: 1px solid #f87171; border-radius: 6px; cursor: pointer; }
.chat-message-header .btn-stream-cancel:hover { background: rgba(248, 113, 113, 0.15); }
.chat-message-header .btn-stream-cancel:disabled { opacity: 0.5; cursor: not-allowed; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.chat-widget-preview { padding: 10px; }
.chat-widget-preview-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chat-widget-preview .btn { padding: 6px 12px; border-radius: 6px; font-size: 12px; text-decoration: none; cursor: pointer; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); }
.chat-widget-preview .btn-preview { background: var(--accent); color: #fff; border-color: var(--accent); }
.chat-widget-preview .btn-feedback { padding: 4px 8px; font-size: 14px; border: 1px solid var(--border); background: transparent; cursor: pointer; border-radius: 6px; }
.chat-widget-preview .btn-feedback:hover { background: var(--bg-input); }
.chat-widget-preview .btn-feedback.active { background: rgba(63, 185, 80, 0.2); border-color: var(--success); }
.chat-widget-preview .btn-feedback-dislike.active { background: rgba(248, 113, 113, 0.2); border-color: #f87171; }
.analysis-summary { font-weight: 500; margin: 6px 0 4px; color: var(--text); }
.chat-widget-preview .btn-publish-preview { padding: 4px 12px; font-size: 13px; background: #2563eb; color: #fff; border: 0; border-radius: 6px; cursor: pointer; }
.chat-widget-preview .btn-publish-preview:hover { background: #3b82f6; }
.chat-widget-preview .btn-unpublish-preview { padding: 4px 12px; font-size: 13px; background: #64748b; color: #fff; border: 0; border-radius: 6px; cursor: pointer; }
.chat-widget-preview .btn-unpublish-preview:hover { background: #94a3b8; }
.chat-widget-preview .publish-blocked-hint { font-size: 12px; color: #f59e0b; padding: 4px 8px; }
.publish-dialog .publish-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.publish-dialog .publish-status { padding: 20px 0; text-align: center; }
.publish-dialog .publish-status-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: #94a3b8; }
.publish-dialog .publish-spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid #334155; border-top-color: #60a5fa; border-radius: 50%; animation: publish-spin 0.8s linear infinite; }
@keyframes publish-spin { to { transform: rotate(360deg); } }
.publish-dialog .publish-status-success { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #34d399; }
.publish-dialog .publish-check { font-size: 28px; font-weight: bold; }
.publish-dialog .btn-publish-catalog { display: inline-block; padding: 8px 16px; background: #2563eb; color: #fff; border-radius: 6px; text-decoration: none; font-size: 14px; }
.publish-dialog .btn-publish-catalog:hover { background: #3b82f6; }
.publish-dialog .publish-success-actions { display: flex; gap: 10px; justify-content: center; margin-top: 4px; }
.publish-dialog .publish-status-failure { color: #f87171; }
.publish-dialog .publish-field label { font-size: 12px; color: #9ca3af; }
.publish-dialog .publish-version { font-weight: 600; color: #e5e7eb; }
.publish-dialog .publish-hint { font-size: 11px; color: #6b7280; margin-bottom: 10px; }
.publish-dialog .btn-publish { background: #2563eb; color: #fff; }
.btn-delete-version { background: transparent; color: #f87171; border: 1px solid #f87171; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-delete-version:hover { background: rgba(248, 113, 113, 0.15); }
.btn-delete-version:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-widget-retry .btn-retry-create { margin-top: 8px; padding: 8px 14px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; cursor: pointer; font-size: 14px; }
.chat-widget-retry .btn-retry-create:hover { opacity: 0.9; }
.chat-input {
  position: fixed;
  bottom: 40px;
  width: 710px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: end;
  background: #19253d;
  border-radius: 28px;
  padding: 12px;
  transition: height .2s ease-in-out;
  overflow: hidden;
  box-sizing: content-box;
}
.chat-input-row { 
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}
.chat-tools-row #chat-role-select { padding: 6px 10px; border-radius: 6px; border: 1px solid #374151; background: #0f172a; color: #e5e7eb; font-size: 13px; }
.chat-prompt-send-button .send-button {
  background: var(--btn-brandprimary-fill);
  color: var(--btn-brandprimary-text);
}
.chat-prompt-send-button .send-button, .chat-prompt-send-button .stop-button {
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  border-radius: 50%;
  font-size: 24px;
}
#chat-input {
  width: 100%;
  font-size: 16px;
  padding: 4px 8px;
  line-height: 24px;
  min-height: 32px;
  max-height: 170px;
  height: 32px;
  overflow-y: auto;
  resize: none;
  box-sizing: border-box;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  color: var(--character-primary-text);
  caret-color: var(--character-brandprimary-text);
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
#chat-input::-webkit-scrollbar { width: 6px; opacity: 0; -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease; }
#chat-input::-webkit-scrollbar-track { background: transparent; }
#chat-input::-webkit-scrollbar-thumb { background-color: var(--container-quaternary-fill); border-radius: 3px; opacity: 0; -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease; }
#chat-input:hover::-webkit-scrollbar-thumb,
#chat-input:active::-webkit-scrollbar-thumb,
#chat-input:focus::-webkit-scrollbar-thumb { opacity: 1; }
#chat-input:hover::-webkit-scrollbar,
#chat-input:active::-webkit-scrollbar,
#chat-input:focus::-webkit-scrollbar { opacity: 1; }
#chat-input:hover { scrollbar-color: rgba(0, 0, 0, 0.2) transparent; }
#chat-input:focus { scrollbar-color: rgba(0, 0, 0, 0.2) transparent; }
dialog { border: 1px solid #374151; border-radius: 10px; background: #111827; color: #e5e7eb; width: 420px; }
dialog form { display: flex; flex-direction: column; gap: 8px; }
dialog input, dialog textarea { border: 1px solid #374151; border-radius: 8px; background: #0f172a; color: #e5e7eb; padding: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-actions .btn-secondary { background: transparent; color: #9ca3af; border: 1px solid #374151; }
.dialog-actions .btn-secondary:hover { background: rgba(255,255,255,0.06); color: #e5e7eb; }
