@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Aurora global theme */
:root {
  color-scheme: dark;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: #0f172a;
  color: #e2e8f0;

  --bg-gradient: linear-gradient(180deg, rgba(124, 58, 237, 0.32), rgba(15, 23, 42, 0.9));
  --bg-main: rgba(15, 23, 42, 0.9);
  --bg-alt: rgba(15, 23, 42, 0.82);
  --surface: rgba(30, 41, 59, 0.94);
  --surface-solid: #1e293b;
  --surface-border: rgba(51, 65, 85, 0.75);
  --surface-border-strong: rgba(148, 163, 184, 0.65);
  --text-color: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.28);
  --accent-light: rgba(124, 58, 237, 0.18);
  --accent-strong: #7c3aed;
  --positive: #22c55e;
  --negative: #f97316;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.45);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: inherit;
  background: var(--bg-gradient);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
}

.temporarily-hidden-control {
  display: none !important;
}

/* App layout: sidebar + main chat panel */
.app {
  display: flex;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  background: transparent;
}

.app.embed-sidebar-hidden .sidebar,
.app.embed-sidebar-hidden #divider,
.app.embed-sidebar-hidden #thinSidebar,
.app.embed-sidebar-hidden #collapsedSidebarLogo,
.app.embed-sidebar-hidden #expandSidebarArrow,
.app.embed-sidebar-hidden #expandSidebarBtn {
  display: none !important;
}

.app.embed-sidebar-hidden .chat-panel {
  display: flex;
}

/* Sidebar */
.sidebar {
  position: relative;
  width: clamp(260px, 32vw, calc(100vw - 100px));
  max-width: calc(100vw - 100px);
  background: linear-gradient(185deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.92));
  padding: 3.5rem 1.25rem 1.5rem 1.25rem;
  overflow-y: auto;
  border-right: 1px solid var(--surface-border);
  flex: none;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar-subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Draggable divider */
.divider {
  width: 5px;
  cursor: col-resize;
  background: rgba(124, 58, 237, 0.18);
  backdrop-filter: blur(6px);
  border-right: 1px solid rgba(124, 58, 237, 0.32);
  border-left: 1px solid rgba(148, 163, 184, 0.35);
  flex: none;
}

/* Chat Panel in main area */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: clamp(1.25rem, 2.5vw, 2rem);
  background: linear-gradient(170deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.94));
  color: var(--text-color);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  backdrop-filter: blur(8px);
}

/* The controls, tasks table, and other components end up in the sidebar. */
#controls {
  margin-bottom: 1rem;
}

/* Tasks table */
#tasks {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  margin-bottom: 2rem;
  display: table;
  color: var(--text-color);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  overflow: hidden;
}

#tasks th,
#tasks td {
  border: 1px solid rgba(116, 156, 194, 0.15);
  padding: 0.65rem 0.75rem;
}

#tasks th {
  background: rgba(124, 58, 237, 0.14);
  text-align: left;
}

.hidden {
  opacity: 0.6;
}

.drag-handle {
  cursor: move;
}

.arrow {
  margin: 0 2px;
  background: rgba(124, 58, 237, 0.18);
  border: 1px solid rgba(124, 58, 237, 0.45);
  cursor: pointer;
  color: var(--text-color);
  border-radius: 8px;
  padding: 0.25rem 0.45rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.eye {
  cursor: pointer;
  background: rgba(124, 58, 237, 0.18);
  border: 1px solid rgba(124, 58, 237, 0.45);
  color: var(--text-color);
  border-radius: 8px;
  padding: 0.25rem 0.45rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.arrow:hover,
.eye:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.priority-cell,
.status-cell,
.dependencies-cell,
.blocking-cell,
.title-cell,
.project-cell,
.sprint-cell {
  cursor: pointer;
}

/* Filter controls */
#projectFilter,
#sprintFilter {
  margin-left: 4px;
  background: rgba(15, 23, 42, 0.92);
  color: var(--text-color);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 0.35rem 0.6rem;
}

#projectFilter:focus,
#sprintFilter:focus {
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.35);
}

/* Modal styling */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--surface);
  color: var(--text-color);
  padding: 1.25rem;
  position: relative;
  width: 90%;
  max-width: 600px;
  margin: auto;
  border-radius: 18px;
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

#renameTabTimestamps {
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: none;
}

.modal-buttons {
  margin-top: 1rem;
  text-align: right;
}

.modal-buttons button {
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  margin-left: 4px;
  cursor: pointer;
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.modal-buttons button:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.disabled-setting {
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#defaultModelSection select:disabled {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: rgba(148, 163, 184, 0.4);
}

.disabled-setting-note {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.col-item {
  margin: 4px 0;
}

.col-move {
  margin-right: 4px;
  background: rgba(124, 58, 237, 0.18);
  border: 1px solid rgba(124, 58, 237, 0.4);
  color: var(--text-color);
  border-radius: 10px;
}

/* Chat panel area */
#chatPanel {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

#chatMessages {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: clamp(0.75rem, 1.4vw, 1.25rem);
  flex: 1 1 auto;
  min-height: 0;
  color: var(--text-color);
  box-shadow: var(--shadow);
}

/* The waiting counter */
#waitingCounter {
  font-size: 0.9rem;
  color: var(--text-muted);
  height: 1.2em;
  margin-bottom: 0.5rem;
}

/* Chat message bubble grouping */
.chat-sequence {
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.96));
  border: none;
  border-radius: 18px;
  padding: clamp(0.85rem, 1.5vw, 1.25rem);
  margin-bottom: 1rem;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.delete-chat-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.delete-chat-btn:hover {
  color: var(--accent);
}

.archive-action-btn {
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.archive-action-btn:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-color);
  border-color: var(--surface-border-strong);
}

.archive-delete-btn {
  border-color: rgba(249, 115, 22, 0.45);
  color: var(--negative);
}

.archive-delete-btn:hover {
  background: rgba(249, 115, 22, 0.18);
  color: #fff;
  border-color: var(--negative);
}

.pair-delete-btn {
  position: absolute;
  bottom: 4px; /* place at bottom to avoid overlap with bubble delete */
  right: 4px;
  padding: 4px;
}

.download-chat-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 1.1rem;
  text-shadow: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.download-chat-btn:hover {
  color: var(--accent);
}

.pair-download-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  padding: 4px;
}

.table-download-btn {
  margin-left: 4px;
}

.bubble-delete-btn {
  position: absolute;
  top: 4px; /* align inside bubble */
  right: 4px;
  line-height: 1; /* consistent vertical alignment */
  font-size: 1rem;
}

.model-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.model-delete-btn:hover {
  color: var(--accent);
}

.bubble-copy-btn {
  position: absolute;
  top: 4px;
  right: 36px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}

.chat-user .bubble-copy-btn,
.chat-user .bubble-edit-btn,
.chat-user .bubble-delete-btn {
  top: -3px;
}

.bubble-edit-btn {
  position: absolute;
  top: 4px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}

.bubble-copy-btn:hover {
  color: var(--accent-strong);
}

.code-copy-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
}

.code-copy-btn:hover {
  color: var(--accent-strong);
}

/* Avatars replaced with name ovals */
.name-oval {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  margin-right: 6px;
  color: #fff;
}

.name-oval-user {
  background: rgba(118, 190, 255, 0.7);
}

.name-oval-ai {
  background: rgba(255, 195, 112, 0.82);
}

/* Bubble headers, containing name oval + timestamp */
.bubble-header {
  display: flex;
  align-items: center;
  gap: 8px; /* increased for better spacing */
  margin-bottom: 6px; /* increased for a bit more breathing room */
  font-size: 0.9rem;
  position: relative;
}

/* Extra space to place buttons above timestamp */
.chat-user .bubble-header {
  padding-top: 16px;
}

/* Date header separating chat days */
.chat-date-header {
  text-align: center;
  margin: 8px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* User bubble: displayed on the right side */
.chat-user {
  background: linear-gradient(160deg, rgba(124, 58, 237, 0.42), rgba(79, 70, 229, 0.5));
  padding: 12px 14px;
  border-radius: 20px;
  margin-bottom: 12px;
  align-self: flex-end;
  text-align: right;
  max-width: min(70%, 720px);
  color: var(--text-color);
  position: relative;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: monospace;
  border: 1px solid rgba(124, 58, 237, 0.5);
  box-shadow: 0 16px 34px rgba(124, 58, 237, 0.35);
}

/* AI bubble: displayed on the left side */
.chat-bot {
  background: linear-gradient(160deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  padding: 12px 14px;
  border-radius: 20px;
  margin-bottom: 12px;
  display: block;
  max-width: min(70%, 760px);
  color: var(--text-color);
  position: relative;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: monospace;
  border: 1px solid var(--surface-border);
  box-shadow: 0 22px 44px rgba(15, 23, 42, 0.55);
}

.chat-bot.has-model-info {
  padding-bottom: 12px;
}

.chat-model-info {
  position: absolute;
  top: 4px;
  right: 64px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: rgba(15, 23, 42, 0.92);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  cursor: help;
  user-select: none;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  z-index: 5;
}

.chat-model-info-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
}

.chat-model-info:hover,
.chat-model-info:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
  border-color: var(--accent-strong);
}

.chat-model-info:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-model-info::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  max-width: none;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-color);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--surface-border);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.45);
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}

.chat-model-info:hover::after,
.chat-model-info:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

/* Ensure images fit within chat bubbles and cap width */
.chat-user img,
.chat-bot img {
  max-width: min(100%, 400px);
  height: auto;
}

/* Match font sizes between chat bubbles and input box */
.chat-user,
.chat-bot {
  font-size: 0.95rem;
  position: relative;
}

/* Thumbnail for user uploaded images */
.user-image-thumb {
  max-width: 120px;
  max-height: 120px;
  margin: 4px 0;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
}

/* Individual user message within a chat bubble */
.user-subbubble {
  max-width: 100%;
  min-height: 2.2rem; /* extra height for header buttons */
}

.chat-user pre,
.chat-bot pre {
  background: rgba(15, 23, 42, 0.85);
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
  position: relative;
  border: 1px solid rgba(124, 58, 237, 0.35);
}

/* Thumbnail images in the secure uploader table */
.table-thumb {
  max-width: 52px;
  max-height: 52px;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
}

/* Additional details styling */
.chat-system,
.chat-instructions {
  background: rgba(30, 41, 59, 0.92);
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  white-space: pre-wrap;
  border: 1px solid var(--surface-border);
}

/* Modern chat input container */
.chat-input-container {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  margin-top: 0.75rem;
  width: 100%;
  flex: 0 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.chat-input-container textarea {
  border: none;
  background: transparent;
  color: var(--text-color);
  padding: 12px 16px;
  flex: 1;
  outline: none;
  font-size: 0.95rem;
  resize: none;
  min-height: 40px;
  overflow-y: auto;
  font-family: monospace; /* Added to match chat bubbles */
}

.chat-input-container textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #fff;
  border: none;
  outline: none;
  padding: 12px 20px;
  cursor: pointer;
  border-radius: 0 18px 18px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(124, 58, 237, 0.45);
}

.stop-btn {
  background: linear-gradient(120deg, #ff6b6b, #e0435b);
}

.stop-btn:hover {
  box-shadow: 0 12px 24px rgba(255, 107, 107, 0.35);
}

/* Scroll to bottom button: now always visible inline */
#scrollDownBtn {
  background: rgba(30, 41, 59, 0.92);
  color: var(--text-color);
  border: 1px solid var(--surface-border);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-block;
  z-index: 10;
  margin-left: 0.5rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

#scrollDownBtn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Collapsible menus in index */
#toolbarCollapsible {
  margin-bottom: 1rem;
  background: var(--surface);
  padding: 0.85rem;
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
}

/* New sticky toolbar for chat tabs */
#chatTabs {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0;
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

/* When sidebar is collapsed, shift the chat tabs bar to clear the logo */
.app.sidebar-collapsed #chatTabs {
  margin-left: 50px;
}

/* Collapsed sidebar layout */
.app.sidebar-collapsed .sidebar {
  width: 50px !important;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.app.sidebar-collapsed .tree-menu,
.app.sidebar-collapsed [id^="sidebarView"] {
  display: none !important;
}

.app.sidebar-collapsed .icon-menu {
  display: block;
}

/* Icon displayed before chat tab names */
#tabsContainer .tab-icon,
#verticalTabsContainer .tab-icon {
  margin-right: 4px;
  width: 1.2rem;
  text-align: center;
  font-size: 0.9rem;
}

/* Circle icon for exclamation */
.exclamation-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: #f00;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  text-align: center;
  line-height: 20px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
}

/* Buttons container in the top-right corner */
.top-right-buttons {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 0.6rem;
  z-index: 1000;
}

.top-right-buttons .top-btn {
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.top-right-buttons .top-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.subscribe-teaser {
  color: var(--accent);
  align-self: center;
  font-size: 0.82rem;
  font-weight: 500;
}

/* Toggle icon in top-left corner */
.nav-toggle-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  left: auto;
  width: 42px;
  height: 42px;
  cursor: pointer;
  z-index: 1000;
}

/* Sidebar collapse/expand icon */
.sidebar-toggle-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  z-index: 1000;
}

.sidebar-brand-text {
  position: absolute;
  top: 16px;
  left: 60px;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  z-index: 1000;
}

.app.sidebar-collapsed #sidebarBrandText {
  display: none;
}

.close-sidebar-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  z-index: 1000;
}

.app.sidebar-collapsed .close-sidebar-icon {
  display: none;
}

/* Hide large toggle icon when sidebar is collapsed */
.app.sidebar-collapsed #sidebarToggleIcon {
  display: none;
}

/* Display session ID next to the sidebar icon */
#sessionIdText.session-id {
  display: none;
  position: absolute;
  top: 16px;
  left: 152px;
  font-size: 0.8rem;
  color: var(--text-muted);
  z-index: 1000;
  user-select: text;
}

/* Button to hide the sidebar */
#hideSidebarBtn.hide-sidebar-btn {
  position: absolute;
  top: 45px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 1000;
  display: none !important;
}

/* Hide the expand sidebar button for now */
#expandSidebarBtn {
  display: none !important;
}


/* Token count indicator in bottom-right corner of subbubble */
.token-indicator {
  position: absolute;
  right: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* Token counter shown below the chat input */
.token-counter {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 6px;
  text-align: right;
}

/* Citation card shown below AI reply */
.chat-citations {
  background: var(--surface);
  padding: 0.75rem 1rem;
  border-radius: 14px;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  border: 1px solid var(--surface-border);
}
.chat-citations ul {
  list-style: decimal inside;
  margin: 0;
  padding-left: 1em;
}
.chat-citations a {
  color: var(--accent);
}

/* Additional styling for the new Chat Tabs sidebar panel */
#sidebarViewChatTabs {
  margin-top: 1rem;
}

#verticalTabsContainer button {
  display: inline-flex;
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  align-items: center;
  text-align: left;
  border-radius: 12px;
  gap: 0.4rem;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

#verticalTabsContainer button:hover {
  background-color: var(--accent-light);
  border-color: var(--accent);
  transform: translateX(2px);
}


/* Creation date text for sidebar chat tabs */
#verticalTabsContainer .tab-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
#tabsContainer .tab-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
#archivedTabsContainer .tab-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#archivedTabsContainer .archived-empty-state {
  padding: 0.5rem 0;
}

/* Date header separating chat tabs by day */
#verticalTabsContainer .tab-date-header {
  margin: 4px 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Project header separating chat tabs by project */
#verticalTabsContainer .tab-project-header {
  margin: 6px 0 2px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
}
#archivedTabsContainer .tab-project-header {
  margin: 6px 0 2px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
}
#verticalTabsContainer .tab-project-header .drag-handle {
  cursor: move;
  margin-right: 4px;
}
#verticalTabsContainer .tab-project-header.drag-over {
  border: 1px dashed var(--accent-light);
}
#verticalTabsContainer .project-collapse-arrow {
  margin-right: 4px;
}
#archivedTabsContainer .project-collapse-arrow {
  margin-right: 4px;
}
#verticalTabsContainer .child-collapse-arrow,
#archivedTabsContainer .child-collapse-arrow {
  margin-right: 2px;
  cursor: pointer;
}

#verticalTabsContainer .project-gear-btn {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  margin-left: 4px;
  transition: color 0.3s;
  width: 24px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#verticalTabsContainer .project-add-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
  margin-left: 4px;
  transition: color 0.3s;
  width: 24px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#verticalTabsContainer .project-search-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
  margin-left: 4px;
  transition: color 0.3s;
  width: 24px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#verticalTabsContainer .project-gear-btn:hover {
  color: var(--accent-light);
}
#verticalTabsContainer .project-add-btn:hover {
  color: var(--accent-light);
}
#verticalTabsContainer .project-search-btn:hover {
  color: var(--accent-light);
}

.project-toolbar-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 4px 6px;
  display: none;
  z-index: 10000;
  box-shadow: var(--shadow);
}
.tab-options-trigger {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-options-trigger:hover,
.tab-options-trigger:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent-light);
  outline: none;
}

.tab-options-menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 4px 0;
  box-shadow: var(--shadow);
  z-index: 12000;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.tab-options-menu.visible {
  opacity: 1;
  transform: translateY(0);
}

.tab-options-menu .tab-options-item {
  background: none;
  border: none;
  color: var(--text-color);
  padding: 8px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-options-menu .tab-options-item:hover,
.tab-options-menu .tab-options-item:focus-visible {
  background: var(--accent-light);
  color: #fff;
  outline: none;
}
.project-toolbar-tooltip .project-search-btn {
  margin-left: 0;
}

#projectGroupsContainer button {
  display: inline-flex;
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  padding: 0.55rem 0.75rem;
  cursor: move;
  align-items: center;
  text-align: left;
  border-radius: 12px;
  font-weight: 600;
  margin: 6px 0 2px;
  gap: 0.35rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}
#projectGroupsContainer button.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
#verticalTabsContainer .project-indented {
  margin-left: 10px;
}
#archivedTabsContainer .project-indented {
  margin-left: 10px;
}
#verticalTabsContainer .subtask-indented {
  margin-left: 20px;
}
#archivedTabsContainer .subtask-indented {
  margin-left: 20px;
}

#verticalTabsContainer .sidebar-tab-row.drag-over {
  border: 1px dashed var(--accent-light);
}
#verticalTabsContainer .sidebar-tab-row.sub-drop-bar {
  border-bottom: 2px solid var(--accent-light);
}
#verticalTabsContainer .top-drop-bar {
  border-top: 2px solid var(--accent-light);
  height: 0;
  margin-bottom: 2px;
}
#archivedTabsContainer .sidebar-tab-row.sub-drop-bar {
  border-bottom: 2px solid var(--accent-light);
}
#archivedTabsContainer .top-drop-bar {
  border-top: 2px solid var(--accent-light);
  height: 0;
  margin-bottom: 2px;
}

#verticalTabsContainer .sidebar-tab-row .drag-handle {
  cursor: move;
}

#verticalTabsContainer button.active {
  background-color: var(--accent-light);
  border-color: rgba(124, 58, 237, 0.55);
  color: #fff;
}

/* Highlight chat tab title while waiting for AI response */
.tab-processing {
  color: transparent !important;
  background-image: linear-gradient(90deg, #7c3aed, #a855f7, #7c3aed);
  background-size: 200% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  animation: tab-wave 2s linear infinite;
}

@keyframes tab-wave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

#verticalTabsContainer .task-id,
#archivedTabsContainer .task-id {
  margin-left: auto;
  color: var(--accent-light);
  font-size: 0.8rem;
  padding-left: 4px;
  cursor: pointer;
}

/* Secure uploader file table */
#secureFilesList {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

#secureFilesList th,
#secureFilesList td {
  border: 1px solid rgba(51, 65, 85, 0.6);
  padding: 0.6rem 0.75rem;
}

#secureFilesList th {
  background: var(--accent-light);
  text-align: left;
}

/* Hide the UUID/hash column */
#secureFilesList th[data-col="uuid"],
#secureFilesList td.uuid-col {
  display: none;
}

/* Links in the secure uploader table */
#secureFilesList a {
  color: var(--accent);
}
#secureFilesList a:visited {
  color: var(--accent);
}

/* Hide file name column in image table */
#secureFilesList th[data-col="name"],
#secureFilesList td.name-col {
  display: none;
}


/* Pipeline queue table */
#queueTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

#queueTable th,
#queueTable td {
  border: none;
  padding: 0.55rem 0.75rem;
}

#queueTable th:nth-child(1),
#queueTable td:nth-child(1) {
  display: none;
}

#queueTable tbody tr:nth-child(odd) {
  background-color: rgba(30, 41, 59, 0.92);
}

#queueTable tbody tr:nth-child(even) {
  background-color: rgba(17, 24, 39, 0.92);
}

#queueTable th {
  background: var(--accent-light);
  text-align: left;
}



/* New gear icon for the Markdown area */
#markdownGearIcon {
  position: relative;
  z-index: 9999;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 4px;
}

/* Gear icon inside search/reasoning tooltips */
.tooltip-gear {
  position: absolute;
  top: 2px;
  right: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.tooltip-gear.active {
  color: var(--accent);
}

/* Star icon style used in AI Favorites modal */
.favorite-star {
  cursor: pointer;
  font-size: 1.2rem;
  user-select: none;
}
.starred { color: gold; }
.unstarred { color: #777; }

/* Basic style for chat subroutine cards */
.subroutine-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  padding: 0.75rem;
  width: 180px;
  height: 96px;
  color: var(--text-color);
  position: relative;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.subroutine-card .edit-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.8rem;
  cursor: pointer;
}

#mosaicPanel .mosaic-edit-btn {
  margin-left: 6px;
  font-size: 0.8rem;
}

/* View tabs above chat panel */
.view-tab {
  background: var(--surface);
  color: var(--text-color);
  border: 1px solid var(--surface-border);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.view-tab.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Printify Pipeline stage list */
#stageList {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1rem;
}

#stageList li {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  color: var(--text-color);
}

#stageList li.current {
  background: var(--accent-light);
  color: var(--accent);
}

#stageList li.completed {
  background: rgba(61, 213, 152, 0.25);
  color: #167a56;
}

#stageList li.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Inline loading spinner used in status indicators */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-right-color: transparent;
  animation: loading-spin 0.75s linear infinite;
}

.loading-more {
  text-align: center;
  padding: 4px;
}

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

#navSpinner {
  text-align: center;
  margin-bottom: 1rem;
}

#navSpinner .loading-spinner {
  margin-left: 0;
  width: 24px;
  height: 24px;
  border-width: 3px;
}

/* Full page loader overlay */
.page-loader {
  display: none;
  position: fixed;
  z-index: 10002;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.page-loader.show {
  display: flex;
}

.nav-placeholder {
  width: 100%;
  height: 1.2rem;
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.18), rgba(168, 85, 247, 0.32), rgba(124, 58, 237, 0.18));
  background-size: 220% 100%;
  border-radius: 999px;
  margin: 4px 0;
  animation: nav-skeleton-loading 1.4s ease infinite;
}

@keyframes nav-skeleton-loading {
  0% { background-position: 220% 0; }
  100% { background-position: -220% 0; }
}

/* Sidebar tree navigation */
.tree-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tree-button {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.tree-button:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.tree-button.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: #fff;
}

/* Icon menu for collapsed sidebar */
.icon-menu {
  display: none;
  padding: 0;
  margin-top: 1rem;
}

.icon-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  padding: 0.6rem 0;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.icon-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: #fff;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: var(--accent-light);
  border-color: var(--accent);
}

/* Thin sidebar shown when main sidebar is collapsed */
.thin-sidebar {
  position: absolute;
  top: 120px;
  left: 8px;
  width: 42px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 6px 0;
  display: none;
  flex-direction: column;
  align-items: center;
  z-index: 1001;
  backdrop-filter: blur(8px);
}
.app.sidebar-collapsed #expandSidebarArrow {
  display: block;
}
#expandSidebarArrow {
  position: absolute;
  top: 20px;
  left: 48px;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  z-index: 1000;
}
.app.sidebar-collapsed .thin-sidebar {
  display: flex;
}
.thin-sidebar .thin-icon {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.2rem;
  margin: 10px 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.thin-sidebar .thin-icon img {
  width: 24px;
  height: 24px;
  display: block;
  pointer-events: none;
}

.thin-sidebar .thin-icon:hover {
  color: var(--accent);
}

/* Version info in sidebar */
.version-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Footer at the bottom of the sidebar */
.sidebar-footer {
  margin-top: auto;
  font-size: 0.85rem;
  text-align: center;
  color: var(--text-muted);
}

.sidebar-footer a {
  color: var(--accent);
  text-decoration: none;
  margin: 0 0.35rem;
  transition: color 0.2s ease;
}

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

/* Simple toast notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(124, 58, 237, 0.92);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10001;
}

.toast.show {
  display: block;
  opacity: 1;
}

/* Disabled buttons appear greyed out and inactive */
button:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* New Tab dialog type buttons */
#newTabTypeButtons {
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
}
#newTabTypeButtons .start-type-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 80px;
  background: var(--bg-main);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.3s, color 0.3s;
}
#newTabTypeButtons .start-type-btn .icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}
#newTabTypeButtons .start-type-btn.selected {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #fff;
}

/* Ensure the New Tab modal follows the light theme */
#newTabModal .modal-content,
#newTabModal label,
#newTabModal input,
#newTabModal textarea,
#newTabModal button {
  color: var(--text-color);
}
#newTabModal input,
#newTabModal textarea {
  background: var(--surface-solid);
  border: 1px solid var(--surface-border);
}

/* Temporarily hide the chat image generation button */
#chatGenImageBtn {
  display: none !important;
}

/* Queued chat bubbles */
.chat-queue-container {
  position: absolute;
  bottom: 60px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 1000;
}

.chat-queue-bubble {
  background: var(--surface);
  color: var(--text-color);
  border-radius: 14px;
  padding: 0.5rem 0.75rem;
  max-width: 250px;
  font-size: 0.9rem;
  opacity: 0.9;
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
}

/* Cookie consent banner */
#cookieBanner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-alt);
  color: var(--text-color);
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--surface-border);
  display: none;
  z-index: 1100;
  text-align: center;
}

#cookieBanner button {
  margin-left: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  border-radius: 999px;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#cookieBanner button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(124, 58, 237, 0.45);
}

/* Banner shown when a feature requires Pro plan */
.pro-banner {
  margin-top: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}


/* Project search input and button */
#projectSearchInput {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  padding: 0.4rem 0.6rem;
  border-radius: 12px;
}
#projectSearchBtn {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #fff;
  border: none;
  padding: 0.45rem 0.75rem;
  margin-left: 4px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#projectSearchBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(124, 58, 237, 0.45);
}

/* Reasoning toggle button and image upload button */
#reasoningToggleBtn,
#chatImageBtn {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
  cursor: pointer;
  margin-right: 0.5rem;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

#reasoningToggleBtn:hover,
#chatImageBtn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: translateY(-1px);
}


.reasoning-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 0.75rem;
  display: none;
  z-index: 10000;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.reasoning-tooltip .tooltip-section-header {
  font-weight: bold;
  color: var(--accent);
  margin-top: 0.5rem;
  margin-bottom: 0.35rem;
}
.reasoning-tooltip button {
  display: block;
  margin: 2px 0;
  padding: 0.35rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.reasoning-tooltip button:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.reasoning-tooltip button.active {
  background: var(--accent-light);
  color: var(--accent);
}

.reasoning-tooltip .model-label {
  display: inline-block;
  font-size: 0.7em;
  padding: 1px 4px;
  margin-right: 4px;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
  text-transform: uppercase;
}
.reasoning-tooltip .model-provider {
  color: #999;
  margin-right: 4px;
}
.reasoning-tooltip .model-row-header {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.reasoning-tooltip .model-row-provider { color: var(--text-muted); }
.reasoning-tooltip .model-row-name { color: var(--text-color); font-weight: 500; }
.reasoning-tooltip .model-label.ultimate {
  background: #8e44ad;
}

.reasoning-tooltip .model-card {
  width: 220px;
  margin: 4px 0;
}

.reasoning-tooltip .model-note {
  font-size: 0.75em;
  color: var(--text-muted);
  margin-left: 1.4em;
  margin-top: 2px;
}

.reasoning-tooltip button .model-note {
  display: block;
  margin: 2px 0 0;
  margin-left: 0;
}

/* Tooltip listing manually favorited models */
.favorites-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 0.75rem;
  display: none;
  z-index: 10000;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.favorites-tooltip button {
  display: block;
  margin: 2px 0;
  padding: 0.35rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-color);
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
.favorites-tooltip button:hover {
  background: var(--accent-light);
  color: var(--accent);
}


/* Minimal markdown highlighting */
.md-h1,.md-h2,.md-h3,.md-h4,.md-h5,.md-h6{
  display:block;
  font-weight:bold;
}
.md-h1{font-size:1.4rem;}
.md-h2{font-size:1.3rem;}
.md-h3{font-size:1.2rem;}
.md-h4{font-size:1.1rem;}
.md-h5{font-size:1rem;}
.md-h6{font-size:0.95rem;}

.md-bold{font-weight:bold;}
.md-italic{font-style:italic;}
.md-inline-code{
  font-family:monospace;
  background:rgba(227, 238, 250, 0.84);
  padding:4px 6px;
  border-radius:10px;
  border:1px solid rgba(116, 156, 194, 0.3);
}

/* Links generated from applyMarkdownSyntax */
.md-link {
  color: var(--accent);
}


