::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2f2f2f; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* Sidebar */
#sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

#sidebar.ready {
  transition: width 0.15s ease, transform 0.15s ease;
}

@media (min-width: 1024px) {
  #sidebar {
    width: 260px;
  }
  #sidebar.collapsed {
    width: 0;
  }
}

@media (max-width: 1023px) {
  #sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fade-in 0.2s ease-out;
}

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

.img-skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.03) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.03) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}

@keyframes dot-bounce {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

.thinking-dot {
  animation: dot-bounce 1.4s infinite ease-in-out both;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

#prompt-input {
  min-height: 24px;
}

/* Product search */
.product-result-item + .product-result-item {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.product-search-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: #10a37f;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Markdown content in assistant messages */
.markdown-content > *:first-child { margin-top: 0; }
.markdown-content > *:last-child { margin-bottom: 0; }

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-weight: 600;
  margin: 1.25em 0 0.5em;
  line-height: 1.35;
  color: #fff;
}
.markdown-content h1 { font-size: 1.4em; }
.markdown-content h2 { font-size: 1.2em; }
.markdown-content h3 { font-size: 1.05em; }

.markdown-content p { margin: 0.6em 0; }

.markdown-content strong {
  font-weight: 600;
  color: #fff;
}

.markdown-content blockquote {
  border-left: 3px solid rgba(255, 255, 255, 0.15);
  padding: 0.4em 1em;
  margin: 0.75em 0;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 8px 8px 0;
}
.markdown-content blockquote p { margin: 0.25em 0; }

.markdown-content ul,
.markdown-content ol {
  padding-left: 1.5em;
  margin: 0.6em 0;
}
.markdown-content ul { list-style-type: disc; }
.markdown-content ol { list-style-type: decimal; }
.markdown-content li { margin: 0.2em 0; }
.markdown-content li > ul,
.markdown-content li > ol { margin: 0.2em 0; }

.markdown-content hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 1.5em 0;
}

.markdown-content code {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

.markdown-content pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 1em;
  overflow-x: auto;
  margin: 0.75em 0;
}
.markdown-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
  line-height: 1.6;
}

.markdown-content .table-wrapper {
  overflow-x: auto;
  margin: 0.75em 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875em;
  line-height: 1.5;
}
.markdown-content table th,
.markdown-content table td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5em 0.75em;
  text-align: left;
}
.markdown-content table th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
  color: #fff;
}
.markdown-content table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.markdown-content a {
  color: #10a37f;
  text-decoration: underline;
  text-decoration-color: rgba(16, 163, 127, 0.3);
}
.markdown-content a:hover {
  text-decoration-color: #10a37f;
}

/* Conversation / Trainer delete button: gradient fade on the left so text doesn't look clipped */
.conv-item .conv-delete-btn,
.trainer-item .trainer-delete-btn {
  pointer-events: none;
}
.conv-item:hover .conv-delete-btn,
.trainer-item:hover .trainer-delete-btn {
  pointer-events: auto;
}

/* Trainer entry pairs: visual separator between Q&A pairs */
.entry-pair + .entry-pair {
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* Datasets: stepper chevron rotation */
.trainer-chevron {
  transition: transform 0.15s ease;
}

/* Datasets: JSONL viewer */
.jsonl-viewer {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

.jsonl-line-num {
  user-select: none;
  min-width: 2.5rem;
}

/* ---- Listing Optimizer: Patch Review Panel ---- */

.patch-card {
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.patch-card:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.patch-card-excluded {
  opacity: 0.45;
}

.patch-toggle {
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #10a37f;
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background-color 0.15s;
}

.patch-toggle:checked {
  background-color: #10a37f;
  border-color: #10a37f;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}

.patch-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.25);
}

/* Op badges */
.op-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid;
  line-height: 1.4;
  flex-shrink: 0;
}

.op-badge-replace {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.2);
}

.op-badge-add {
  color: #34d399;
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.2);
}

.op-badge-delete {
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.2);
}

.op-badge-merge {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.08);
  border-color: rgba(96, 165, 250, 0.2);
}

/* Diff grid */
.patch-diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .patch-diff-grid {
    grid-template-columns: 1fr;
  }
}

.patch-diff-col {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.patch-diff-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
}

.patch-diff-label-suggested {
  color: #10a37f;
}

.patch-value-current {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 8px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.patch-value-empty {
  font-size: 12px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 8px 12px;
}

.patch-value-delete {
  font-size: 12px;
  font-style: italic;
  color: #f87171;
  background: rgba(248, 113, 113, 0.05);
  border: 1px solid rgba(248, 113, 113, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
}

.patch-value-suggested {
  width: 100%;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(16, 163, 127, 0.04);
  border: 1px solid rgba(16, 163, 127, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  resize: vertical;
  min-height: 2.5rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.patch-value-suggested:focus {
  outline: none;
  border-color: rgba(16, 163, 127, 0.4);
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

/* Product info bar chevron transition */
.pib-chevron {
  transition: transform 0.2s ease;
}

/* GUI JSON Editor */
.gui-field {
  width: 100%;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.gui-field:focus {
  outline: none;
  border-color: rgba(16, 163, 127, 0.4);
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}
.gui-field::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.gui-select {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 5px 28px 5px 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.4)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.gui-select:focus {
  outline: none;
  border-color: rgba(16, 163, 127, 0.4);
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}
.gui-select option {
  background: #1e1e1e;
  color: #fff;
}

.gui-entry-card {
  transition: background-color 0.15s ease;
}
.gui-entry-card:hover {
  background-color: rgba(255, 255, 255, 0.015);
}

.gui-value-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.gui-value-textarea {
  width: 100%;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(16, 163, 127, 0.04);
  border: 1px solid rgba(16, 163, 127, 0.15);
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
  min-height: 2.5rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
.gui-value-textarea:focus {
  outline: none;
  border-color: rgba(16, 163, 127, 0.4);
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}
.gui-value-textarea::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.gui-lang-tag {
  width: 56px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px 4px;
  margin-top: 2px;
  transition: border-color 0.15s;
}
.gui-lang-tag:focus {
  outline: none;
  border-color: rgba(16, 163, 127, 0.4);
}

/* Spin animation for loading indicators */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.animate-spin {
  animation: spin 1s linear infinite;
}

/* Line clamp utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
