/* === CSS Variables === */
:root {
  /* Colors */
  --primary-yellow: #ffe066;
  --primary-yellow-dark: #ffd43b;
  --accent-gold: #e6b800;
  --accent-gold-dark: #bfa100;
  
  --text-primary: #222;
  --text-secondary: #555;
  --text-muted: #666;
  
  --bg-primary: #fffbe9;
  --bg-secondary: #fff8dd;
  --bg-tertiary: #fff5d1;
  
  /* Cohesive Button Color Palette */
  --success-primary: #2d7f47;
  --success-hover: #236338;
  --success-light: #e8f5e8;
  
  --danger-primary: #c8586c;
  --danger-hover: #a94858;
  --danger-light: #fdf2f4;
  
  --info-primary: #5b8db8;
  --info-hover: #4a7396;
  --info-light: #f0f5fa;
  
  --neutral-primary: #6b7280;
  --neutral-hover: #4b5563;
  --neutral-light: #f9fafb;
  
  --purple-primary: #8b5a96;
  --purple-hover: #744f7e;
  --purple-light: #f5f1f6;
  
  /* Status Colors */
  --status-green: #28a745;
  --status-red: #dc3545;
  --status-yellow: #ffc107;
  --status-gray: #6c757d;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s ease;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Arial', sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 20%, rgba(255, 224, 102, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 212, 59, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 3rem 0.5rem 1rem;
  font-size: 1.25rem;
  font-weight: 500;
  background: transparent;
  letter-spacing: 0.02em;
  position: relative;
  transition: var(--transition-medium);
}

.navbar-brand {
  display: flex;
  align-items: center;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.brand-title a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-icon {
  width: 1.5rem;
  height: 1.5rem;
  vertical-align: middle;
}

.navbar-links {
  display: flex;
  gap: 2.5rem;
}

.navbar-links a {
  color: #444;
  text-decoration: none;
  transition: var(--transition-fast);
}

.navbar-links a:hover {
  color: var(--accent-gold);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 60vh;
  margin-top: 2rem;
  padding-top: 1rem;
}

.site-footer {
  background: transparent;
  padding-top: 0.5rem;
  margin-top: auto;
}

.dad-joke {
  color: #4ca64c;
  font-size: 1.12rem;
  text-align: center;
  margin-bottom: 0.5rem;
  opacity: 0.98;
  letter-spacing: 0.01em;
  padding: 0.2em 0;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  background: none;
  border-radius: 0;
  display: block;
}

.copyright {
  text-align: center;
  font-size: 0.95rem;
  color: #aaa;
  margin-bottom: 0.5rem;
}

/* Tab and Chat UI Styling */
.tab-container {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 2em;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  min-width: 320px;
  width: 100%;
  margin-left: 1rem;
  margin-right: 1rem;
  /* Removing only the bottom border and shadow for the content tab gap to look nicer */
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0);
  border-bottom: none;    
}

.tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  align-items: center;
  padding: 0 1rem;
  justify-content: space-between;
}

.tabs .tab-group {
  display: flex;
  align-items: center;
}

.tab {
  padding: 1em 2em;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 1.1em;
  color: #666;
  transition: color 0.2s;
}

.tab.active {
  border-bottom: 2px solid #e6b800;
  color: #e6b800;
  font-weight: bold;
  background: #fafafa;
}

/* Model Status Indicator integrated into tab bar */
.model-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  min-height: 38px;
  font-size: 0.9rem;
  position: relative;
}

/* Wrapper for the select element with embedded status light */
.model-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.status-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  z-index: 10;
}

.status-light::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 0.3;
  animation: pulse-glow 2s infinite;
}

/* Online model unloaded status (yellow) */
.model-status-indicator.online .status-light {
  background:  var(--status-yellow);
  box-shadow: 0 0 8px rgba(40, 167, 69, 0.6);
}

.model-status-indicator.online .status-light::before {
  background:  var(--status-yellow);
}

/* Online model loading status (yellow) */
.model-status-indicator.loading .status-light {
  background:  var(--status-yellow);
  box-shadow: 0 0 8px rgba(40, 167, 69, 0.6);
}

.model-status-indicator.loading .status-light::before {
  background:  var(--status-yellow);
}

/* Offline status (red) */
.model-status-indicator.offline .status-light {
  background: var(--status-red);
  box-shadow: 0 0 8px rgba(220, 53, 69, 0.6);
}

.model-status-indicator.offline .status-light::before {
  background: var(--status-red);
}

/* Online model loaded status (with model name) */
.model-status-indicator.loaded .status-light {
  background: var(--status-green);
  box-shadow: 0 0 8px rgba(40, 167, 69, 0.6);
}

.model-status-indicator.loaded .status-light::before {
  background: var(--status-green);
}

@keyframes pulse-glow {
  0%, 100% { 
    transform: scale(1);
    opacity: 0.3;
  }
  50% { 
    transform: scale(1.4);
    opacity: 0.1;
  }
}

/* Base styles for the select element */
.model-select {
  padding: 0.5rem 0.75rem 0.5rem 1.5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
  font-size: 0.9rem;
  min-width: 180px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align-last: center;
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
}

.model-select:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.2);
}

/* Existing styles for selective coloring based on status */
.model-status-indicator.loaded .model-select {
  color: var(--status-green); /* Green for loaded model */
  font-weight: bold;
}

.model-status-indicator.loading .model-select {
  color: var(--status-gray); /* Gray for loading */
  font-style: italic;
  cursor: wait;
}

.model-status-indicator.online .model-select {
  color: var(--status-yellow); /* Yellow when online but no model loaded */
  font-weight: bold;
}

.model-status-indicator.offline .model-select {
  color: var(--status-red); /* Red when offline */
  font-weight: bold;
}

/* Ensure options in the list are not affected by the select's styling */
.model-select option {
  color: var(--text-primary); 
  font-weight: normal;
  font-style: normal;
  background-color: white; 
  padding: 0.5rem;
}

/* Highlight the selected option ONLY in the open list (if desired) */
.model-select option:checked {
  background-color: #f0f0f0; 
  color: var(--text-primary);
}

.model-select option:checked.server-offline {
  background-color: #f0f0f0; 
  color: var(--status-red);
}

.model-select:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
  opacity: 0.7;
}
/* When server is offline all buttons are disabled and appear muted */
button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  background-color: #cccccc;
  color: #666666;
}

.model-action-btn {
  display: none; /* Hide by default */
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.5rem;
  color: #666;
  margin-left: 0.1rem;
  margin-right: 0.2rem;
  line-height: 1;
}

.model-action-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

/* Unload button is only visible when a model is loaded */
.model-status-indicator.loaded .model-action-btn {
  display: flex;
}

.tab-content-wrapper {
   width: 85%;
}

.tab-content {
  display: none;
  padding: 2em;
  background: #fafafa;
  border-radius: 0 0 8px 8px;
  /* adding border and shadow that was removed for the gap look from higher div */
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;  
}

.tab-content.active {
  display: block;
}

/* Chat UI */
.chat-container {
  display: flex;
  flex-direction: column;
  /* Max space available in viewport 
     This also prevents the chat-history section to resize lower than a certain point */
  min-height: calc(100vh - 550px); 
  min-width: 300px;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  /* Use a semi-fixed chat 'window' height so streaming content never expands the page.
     The chat-history area inside will scroll. The CSS variable allows easy tuning. */
  --chat-height: 520px;
  /* Allow vertical resizing by the user while keeping horizontal size fixed.
     Constrain the resize with min/max heights so it stays usable and doesn't overflow the viewport. */
  resize: vertical;
  height: var(--chat-height);
  max-height: calc(100vh - 120px);
  overflow: hidden; /* hide overflow at container level; chat-history will scroll */
}

/* Responsive fallback: if the viewport height is small, cap the chat window to fit */
@media (max-height: 700px) {
  .chat-container {
    height: calc(100vh - 180px); /* leave space for navbar/footer */
  }
}

.chat-history {
  /* Make chat history take remaining space in the chat container and scroll when content
     exceeds this space. This prevents streaming text from expanding the overall layout. */
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1em;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  /* Optional visual hint for scrollable content */
  scrollbar-width: thin;
}

.chat-message {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 0.5em;
}

.chat-message.user {
  align-items: flex-end;
}

.chat-message.llm {
  align-items: flex-start;
}

.chat-bubble {
  max-width: 70%;
  padding: 0.7em 1.1em;
  border-radius: 20px;
  margin-bottom: 2px;
  font-size: 1em;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.10);
  line-height: 1.5;
}

.chat-bubble.user {
  background: linear-gradient(135deg, #ffe066 60%, #ffd43b 100%);
  color: #222;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.chat-bubble.llm {
  background: #f0f0f0;
  color: #222;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.chat-message.system {
  align-items: flex-start;
}

.chat-bubble.system {
  background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
  color: #2d7f47;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  border: 1px solid #c8e6c9;
  font-style: normal;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(45, 127, 71, 0.1);
}

/* Markdown styling within chat bubbles */
.chat-bubble h1,
.chat-bubble h2,
.chat-bubble h3,
.chat-bubble h4,
.chat-bubble h5,
.chat-bubble h6 {
  margin: 0.5em 0 0.3em 0;
  color: inherit;
  font-weight: bold;
}

.chat-bubble h1 { font-size: 1.4em; }
.chat-bubble h2 { font-size: 1.3em; }
.chat-bubble h3 { font-size: 1.2em; }
.chat-bubble h4 { font-size: 1.1em; }
.chat-bubble h5 { font-size: 1.05em; }
.chat-bubble h6 { font-size: 1em; }

.chat-bubble p {
  margin: 0.5em 0;
  line-height: 1.4;
}

.chat-bubble p:first-child {
  margin-top: 0;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble ul,
.chat-bubble ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.chat-bubble li {
  margin: 0.2em 0;
}

.chat-bubble blockquote {
  margin: 0.5em 0;
  padding: 0.5em 1em;
  border-left: 3px solid #ccc;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
  font-style: italic;
}

.chat-bubble code {
  background: rgba(0,0,0,0.1);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
}

.chat-bubble pre {
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 6px;
  padding: 1em;
  margin: 0.5em 0;
  overflow-x: auto;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  line-height: 1.4;
}

.chat-bubble pre code {
  background: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  font-size: inherit;
}

.chat-bubble table {
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 0.9em;
}

.chat-bubble th,
.chat-bubble td {
  border: 1px solid #ddd;
  padding: 0.3em 0.6em;
  text-align: left;
}

.chat-bubble th {
  background: rgba(0,0,0,0.05);
  font-weight: bold;
}

.chat-bubble a {
  color: var(--info-primary);
  text-decoration: none;
}

.chat-bubble a:hover {
  text-decoration: underline;
}

.chat-bubble hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 1em 0;
}

.chat-bubble strong {
  font-weight: bold;
}

.chat-bubble em {
  font-style: italic;
}

.chat-bubble del {
  text-decoration: line-through;
}

/* Special styling for code blocks in LLM bubbles */
.chat-bubble.llm pre {
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
}

/* Apply special styling to inline code elements */
.chat-bubble.llm code {
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
}

/* Remove styling from code elements inside pre blocks */
.chat-bubble.llm pre code {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

.chat-bubble.llm blockquote {
  background: rgba(0,0,0,0.03);
  border-left-color: #999;
}

.chat-input-row {
  display: flex;
  gap: 0.5em;
  padding: 1em;
  background: #f9f9f9;
  border-radius: 0 0 8px 8px;
}

.chat-input-row select {
  min-width: 120px;
  background: #fff;
  color: #222;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5em;
}

.chat-input-row input[type='text'] {
  flex: 1;
  padding: 0.5em;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #222;
}

.input-with-indicator {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

#chat-input {
  flex: 1;
  padding: 0.5em;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #222;
  margin: 0;
  resize: vertical;
  min-height: 40px;
  font-family: inherit;
}

/* Update placeholder style */
#chat-input::placeholder {
  color: #aaa;
  opacity: 1;
  font-style: italic;
}

#attachment-indicator {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: #666;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid #ddd;
}

.chat-input-row button {
  padding: 0.5em 1.2em;
  background: #e6b800;
  color: #222;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 600;
}

#attachment-btn {
    padding: 0.5em 0.8em;
    background: #f0f0f0;
    color: #222;
    border: 1px solid #ddd;
}

#attachment-btn:hover {
    background: #e0e0e0;
}

#clear-attachments-btn {
    padding: 0.5em 0.6em;
    background: #ff6b6b;
    color: white;
    border: 1px solid #ff5252;
    margin-left: 0.2em;
}

#clear-attachments-btn:hover {
    background: #ff5252;
}

.chat-input-row button:hover {
  background: #d4a500;
}

.chat-input-row button:disabled {
  background: #ccc;
  color: #666;
  cursor: not-allowed;
}

/* Image attachment preview styles */
.attachments-preview-container {
  padding: 0.5em 1em 0 1em;
  background: #f9f9f9;
  border-top: 1px solid #e0e0e0;
  display: none;
}

.attachments-preview-container.has-attachments {
  display: block;
}

.attachments-preview-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
  font-size: 0.85em;
  position: relative;
}

.attachment-preview:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  background: #fafafa;
}

.attachment-thumbnail {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  object-fit: cover;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.attachment-filename {
  color: #666;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9em;
  line-height: 1;
}

.attachment-remove-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  margin-left: 4px;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.attachment-remove-btn:hover {
  color: #ff6b6b;
}

.attachment-remove-btn:active {
  transform: scale(0.9);
}

/* Fallback for non-image files or broken images */
.attachment-preview.no-preview .attachment-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px dashed #dee2e6;
  color: #6c757d;
  font-size: 12px;
}

/* Mobile responsive adjustments */
@media (max-width: 600px) {
  .attachments-preview-row {
    gap: 6px;
  }
  
  .attachment-preview {
    padding: 3px 6px;
    gap: 4px;
  }
  
  .attachment-thumbnail {
    width: 18px;
    height: 18px;
  }
  
  .attachment-filename {
    max-width: 100px;
    font-size: 0.8em;
  }
  
  .attachment-remove-btn {
    font-size: 12px;
  }
}

/* Model Management */
.model-mgmt-container {
  display: flex;
  gap: 2em;
  align-items: flex-start;
}

.model-mgmt-pane {
  flex: 1 1 0;
  min-width: 0;
}

.model-mgmt-pane h3 {
  margin-top: 0;
  color: #222;
}

.model-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.model-table td {
  padding: 0.5em 0.75em;
  vertical-align: middle;
  border-bottom: 1px solid #eee;
  color: #222;
}

.model-table tr:last-child td {
  border-bottom: none;
}

.model-table button {
  background: var(--accent-gold);
  color: #222;
  border: none;
  border-radius: 6px;
  padding: 0.4em 1em;
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 4px rgba(230, 184, 0, 0.15);
}

.model-table button:hover {
  background: var(--accent-gold-dark);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(230, 184, 0, 0.25);
}

.installing-btn {
  font-size: 0.75em !important;
  padding: 0.5em 0.8em !important;
  width: auto !important;
  min-width: 90px !important;
  height: 40px !important;
  background: linear-gradient(145deg, rgba(107, 114, 128, 0.15), rgba(107, 114, 128, 0.08)) !important;
  color: var(--neutral-primary) !important;
  border: 1px solid rgba(107, 114, 128, 0.3) !important;
  cursor: wait !important;
  backdrop-filter: blur(8px) !important;
  box-shadow: 
    0 2px 8px rgba(107, 114, 128, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
  font-weight: 500;
  opacity: 1 !important;
  white-space: nowrap !important;
  animation: gentle-pulse 2s ease-in-out infinite !important;
}

/* Model label styles */
.model-label {
  display: inline-block;
  background-color: var(--info-primary);
  color: white;
  padding: 2px 8px;
  margin-left: 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

.model-label.reasoning {
  background-color: var(--neutral-primary);
}

.model-label.vision {
  background-color: var(--info-primary);
}

.model-label.tool-calling {
  background-color: #FFB74D;
}

.model-label.other {
  background-color: var(--success-primary);
}

.model-label.embeddings {
  background-color: var(--purple-primary);
}

.model-label.reranking {
  background-color: #ca4747;
}

.model-label.coding {
  background-color: #ff6b35;
}

.model-labels-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Model Registration Form */
.model-mgmt-register-form {
  background: linear-gradient(135deg, #ffffff 0%, #fefdfb 100%);
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  margin-bottom: 1.5em;
  padding: 1.5em 2em 1.2em 2em;
  max-width: 750px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  position: relative;
  overflow: visible;
  transition: padding 0.3s ease;
}

/* Collapsed state */
.model-mgmt-register-form.collapsed {
  padding: 1.5em 2em 1.2em 2em;
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.model-mgmt-register-form.collapsed .form-content {
  display: none;
}

.model-mgmt-register-form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #e6b800, #f4c842, #e6b800);
  border-radius: 12px 12px 0 0;
}

.model-mgmt-form-title {
  margin-top: 0;
  color: #1a1a1a;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.2em;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.75em;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.model-mgmt-form-title:hover {
  color: #333;
}

/* Collapsed state title margin adjustment */
.model-mgmt-register-form.collapsed .model-mgmt-form-title {
  margin-bottom: 0;
}

.model-mgmt-form-title::before {
  content: '▶';
  font-size: 0.8em;
  color: #666;
  transition: transform 0.3s ease;
  transform-origin: center;
}

/* Rotate chevron when expanded */
.model-mgmt-register-form:not(.collapsed) .model-mgmt-form-title::before {
  transform: rotate(90deg);
}

/* Hide the separate toggle indicator since we're using the gear */
.form-toggle-indicator {
  display: none;
}

/* Specific styling for title tooltip */
.model-mgmt-form-title .tooltip-icon {
  margin-left: 12px;
  font-size: 16px;
}

.model-mgmt-form-title .tooltip-icon::after {
  width: 250px;
  font-size: 13px;
  left: auto;
  right: 0;
  transform: translateX(0);
}

.model-mgmt-form-title .tooltip-icon:hover::after {
  transform: translateX(0) translateY(-2px);
}

.register-form-row {
  display: flex;
  align-items: center;
  gap: 1.2em;
  margin-bottom: 1em;
  padding: 0.1em 0;
  position: relative;
}

.register-form-row-tight {
  margin-bottom: 0.8em;
  align-items: center;
  flex-wrap: wrap;
}

.register-form-row:last-child {
  margin-bottom: 0;
  margin-top: 1.4em;
  padding-top: 1em;
  border-top: 1px solid #f0f0f0;
}

.register-label {
  min-width: 120px;
  color: #333;
  font-weight: 600;
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 0.85em;
}

.register-label.reasoning-inline {
  margin-left: 1.5em;
  font-weight: 500;
  font-size: 0.9em;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.5em;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
}

.register-label.reasoning-inline input[type="checkbox"] {
  transform: scale(1.1);
  accent-color: #e6b800;
}

/* Checkboxes row styling */
.register-checkboxes-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 1em;
  padding: 0.5em 0;
  margin-left: 0;
}

.register-checkboxes-row .register-label.reasoning-inline {
  margin-left: 0;
  padding: 0.4em 0.8em;
  background: #f8f8f8;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.register-checkboxes-row .register-label.reasoning-inline:hover {
  background: #f0f0f0;
}

.register-model-name-group {
  display: flex;
  align-items: stretch;
  flex: 1;
  border-radius: 6px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
  min-width: 0;
}

.register-model-name-group:focus-within {
  box-shadow: 0 2px 12px rgba(230,184,0,0.25);
}

.register-model-prefix {
  background: #e6b800;
  color: #fff;
  font-weight: 600;
  border-radius: 4px 0 0 4px;
  padding: 0.45em 0.7em;
  font-size: 1em;
  border: 1px solid #ddd;
  border-right: none;
}

.styled-prefix {
  background: linear-gradient(135deg, #f8f8f8 0%, #f0f0f0 100%);
  color: #666;
  border: 1px solid #d5d5d5;
  border-right: none;
  border-radius: 6px 0 0 6px;
  padding: 0.6em 0.8em;
  font-size: 0.95em;
  font-family: inherit;
  font-weight: 500;
  height: 100%;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
  min-width: 50px;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

#register-model-name {
  border-radius: 0 6px 6px 0;
  border: 1px solid #d5d5d5;
  border-left: none;
  padding: 0.6em 0.8em;
  font-size: 0.95em;
  background: #fff;
  color: #222;
  flex: 1;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  box-sizing: border-box;
  min-width: 0;
}

#register-model-name:focus {
  border-color: #e6b800;
  box-shadow: 0 2px 12px rgba(230,184,0,0.25);
}

.form-input-wrapper {
  position: relative;
  width: 100%;
}

#register-recipe {
  min-width: 160px;
  flex: 1;
  border-radius: 6px;
  border: 1px solid #d5d5d5;
  padding: 0.6em 0.8em;
  font-size: 0.95em;
  background: #fff;
  color: #222;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  box-sizing: border-box;
}

#register-recipe:focus {
  border-color: #e6b800;
  box-shadow: 0 2px 12px rgba(230,184,0,0.25);
}

.register-doc-link {
  margin-left: 0.8em;
  color: var(--info-primary);
  font-size: 0.9em;
  text-decoration: none;
  transition: all 0.2s ease;
  padding: 0.3em 0.6em;
  border-radius: 4px;
  background: rgba(0,122,204,0.1);
  border: 1px solid rgba(0,122,204,0.2);
  white-space: nowrap;
}

.register-doc-link:hover {
  color: #fff;
  background: var(--info-primary);
  border-color: var(--info-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(91, 141, 184, 0.3);
}
.checkpoint-input-group {
  display: flex;
  align-items: stretch;
  flex: 1;
  border-radius: 6px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
  min-width: 0;
}

.checkpoint-input-group:focus-within {
  box-shadow: 0 2px 12px rgba(230,184,0,0.25);
}

.checkpoint-input-group #register-checkpoint {
  border-radius: 6px 0 0 6px;
  border: 1px solid #d5d5d5;
  border-right: none;
  padding: 0.6em 0.8em;
  font-size: 0.95em;
  background: #fff;
  color: #222;
  flex: 1;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  box-sizing: border-box;
  min-width: 0;
}

.checkpoint-input-group #register-checkpoint:focus {
  border-color: #e6b800;
  box-shadow: 0 2px 12px rgba(230,184,0,0.25);
}

.folder-select-btn {
  background: #f8f9fa;
  border: 1px solid #d5d5d5;
  border-left: none;
  border-radius: 0 6px 6px 0;
  padding: 0.6em 0.8em;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  color: #666;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.folder-select-btn:hover {
  background: #e9ecef;
  color: #333;
}
/*  */

#register-mmproj, #register-checkpoint {
  border-radius: 6px;
  border: 1px solid #d5d5d5;
  padding: 0.6em 0.8em;
  font-size: 0.95em;
  background: #fff;
  color: #222;
  flex: 1;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  box-sizing: border-box;
  min-width: 0;
}

#register-mmproj:focus, #register-checkpoint:focus {
  border-color: #e6b800;
  box-shadow: 0 2px 12px rgba(230,184,0,0.25);
}

#register-submit {
  background: linear-gradient(135deg, #e6b800 0%, #f4c842 100%);
  color: #222;
  border: none;
  border-radius: 8px;
  padding: 0.8em 2em;
  font-weight: 700;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0;
  box-shadow: 0 3px 12px rgba(230,184,0,0.3);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}

#register-submit::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transition: left 0.5s ease;
}

#register-submit:hover:enabled {
  background: linear-gradient(135deg, #d4a500 0%, #e6b800 100%);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(230,184,0,0.4);
}

#register-submit:hover:enabled::before {
  left: 100%;
}

#register-submit:disabled {
  background: linear-gradient(135deg, #ccc 0%, #bbb 100%);
  color: #666;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.register-status {
  margin-left: 1.2em;
  font-size: 0.95em;
  font-weight: 600;
  padding: 0.4em 0.8em;
  border-radius: 6px;
  transition: all 0.2s ease;
}

/* Make placeholder text in Add a Model form lighter and more elegant */
#register-model-form input::placeholder {
    color: #aaa;
    opacity: 1;
    font-style: italic;
}

#register-model-form input:focus::placeholder {
    color: #ccc;
    transform: translateX(4px);
    transition: all 0.2s ease;
}

/* Success status styling */
.register-status.success {
  background: rgba(39, 174, 96, 0.1);
  color: #27ae60;
  border: 1px solid rgba(39, 174, 96, 0.3);
}

/* Error status styling */
.register-status.error {
  background: rgba(200, 88, 108, 0.1);
  color: var(--danger-primary);
  border: 1px solid rgba(200, 88, 108, 0.3);
}

/* Tooltip styles */
.tooltip-icon {
  display: inline;
  color: var(--info-primary);
  font-size: 14px;
  margin-left: 8px;
  cursor: help;
  position: relative;
  text-transform: none;
}

.tooltip-icon:hover {
  color: #0086ef;
}

.tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(28, 28, 30, 0.98);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  width: 200px;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  line-height: 1.4;
  pointer-events: none;
  text-transform: none;
}

.tooltip-icon:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-2px);
}

/* Smart positioning for tooltips near edges */
.tooltip-icon:nth-last-child(-n+2)::after,
.register-form-row:last-child .tooltip-icon::after {
  left: auto;
  right: 0;
  transform: translateX(0);
  width: 180px;
}

.tooltip-icon:nth-last-child(-n+2):hover::after,
.register-form-row:last-child .tooltip-icon:hover::after {
  transform: translateX(0) translateY(-2px);
}

/* Adjust label layout to accommodate tooltip icon */
.register-label {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

/* Adjust reasoning inline label for tooltip */
.register-label.reasoning-inline {
  align-items: center;
}

.register-label.reasoning-inline .tooltip-icon {
  margin-left: 8px;
}

/* Special positioning for reasoning tooltip to prevent overflow */
.register-label.reasoning-inline .tooltip-icon::after {
  left: auto !important;
  right: 0 !important;
  transform: translateX(0) !important;
  width: 160px !important;
  max-width: 260px !important;
  white-space: pre-line !important;
  word-break: break-word !important;
}

.register-label.reasoning-inline .tooltip-icon:hover::after {
  transform: translateX(0) translateY(-2px) !important;
}

@media (max-width: 800px) {
  .model-mgmt-container {
    flex-direction: column;
    gap: 1.5em;
  }
  
  .model-mgmt-pane {
    flex: none;
    width: 100%;
  }
}

@media (max-width: 600px) {
  .title { 
    font-size: 2rem; 
  }
  .navbar { 
    font-size: 1rem; 
    gap: 1.2rem; 
  }
  .main { 
    margin-top: 1rem; 
  }
  .model-mgmt-container {
    gap: 1em;
  }
  
  .tab-container {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    width: calc(100% - 1rem);
  }
  
  /* Ensure all input fields are properly constrained on very narrow screens */
  #register-model-name, #register-mmproj, #register-checkpoint, #register-recipe {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* === Responsive Navbar === */
@media (max-width: 800px) {
  .navbar {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 1rem 0.5rem 1rem;
    align-items: center;
  }
  
  .navbar-brand {
    margin-bottom: 0.5rem;
  }
  
  .brand-title {
    font-size: 1.3rem;
  }
  
  .brand-icon {
    width: 1.3rem;
    height: 1.3rem;
  }
  
  .navbar-links {
    gap: 1.5rem;
    font-size: 1rem;
  }
}

@media (max-width: 600px) {
  .navbar {
    padding: 0.5rem 0.5rem 0.25rem 0.5rem;
  }
  
  .brand-title {
    font-size: 1.2rem;
  }
  
  .brand-icon {
    width: 1.2rem;
    height: 1.2rem;
  }
  
  .navbar-links {
    gap: 1rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .main {
    margin-top: 0.5rem;
  }
}

/* Ensure form container allows tooltip overflow */
.model-mgmt-register-form {
  position: relative;
  overflow: visible;
}

.register-form-row {
  position: relative;
}

/* Additional positioning rules for better tooltip placement */
.register-label .tooltip-icon::after {
  width: 200px;
}

/* Ensure tooltips for rightmost elements don't get cut off */
.register-form-row-tight .tooltip-icon:last-child::after {
  left: auto;
  right: 0;
  transform: translateX(0);
  width: 180px;
}

.register-form-row-tight .tooltip-icon:last-child:hover::after {
  transform: translateX(0) translateY(-2px);
}

.register-form-row-tight .tooltip-icon:last-child::before {
  left: auto;
  right: 8px;
  transform: translateX(0);
}

.register-form-row-tight .tooltip-icon:last-child:hover::before {
  transform: translateX(0) translateY(-2px);
}

/* App Suggestions Section */
.app-suggestions-section {
  margin-top: 2rem;
  padding: 1.5rem 0;
  text-align: center;
  border-top: 1px solid #e0e0e0;
  background: #fafafa;
}

.suggestion-text {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.suggestion-highlight {
  font-size: 1.2rem;
  margin-right: 0.5rem;
  opacity: 0.8;
}

.app-logos-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  flex-wrap: nowrap;
  padding: 0 1rem;
}

.app-logo-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: #fff;
  padding: 0.3rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  position: relative;
}

.app-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.app-logo-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  background: #fff;
}

.app-name {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  transition: color 0.3s ease;
}

/* Fallback styling for broken images */
.app-logo-item.image-failed {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px dashed #dee2e6;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem;
}

.app-logo-item.image-failed:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  border-color: #adb5bd;
}

.app-logo-item.image-failed .app-logo-img {
  display: none;
}

.app-logo-item.image-failed .app-name {
  display: block;
  font-size: 0.7rem;
  color: #6c757d;
  font-weight: 500;
  text-align: center;
  line-height: 1.1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Default hidden state for app names */
.app-logo-item:not(.image-failed) .app-name {
  display: none;
}

@media (max-width: 800px) {
  .app-logos-grid {
    gap: 0.5rem;
    padding: 0 0.5rem;
  }
  
  .app-logo-item {
    width: 48px;
    height: 48px;
  }
  
  .app-logo-img {
    border-radius: 3px;
  }
  
  .suggestion-text {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }
  
  .app-logo-item.image-failed .app-name {
    font-size: 0.6rem;
    line-height: 1.0;
  }
  
  .app-logo-item.image-failed {
    padding: 0.3rem;
  }
}

/* Think tokens styling */
.think-tokens-container {
  margin: 0.5em 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.02);
  transition: all 0.2s ease;
}

.think-tokens-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 0.6em 0.8em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5em;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  transition: all 0.2s ease;
  user-select: none;
}

.think-tokens-header:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.think-tokens-chevron {
  font-size: 0.8em;
  color: #666;
  transition: transform 0.2s ease;
  width: 12px;
  text-align: center;
}

.think-tokens-label {
  font-size: 0.9em;
  font-weight: 600;
  color: #555;
  font-style: italic;
}

.think-tokens-content {
  padding: 1em;
  background: rgba(0,0,0,0.03);
  border-top: 1px solid rgba(0,0,0,0.05);
  display: block;
}

.think-tokens-container.collapsed .think-tokens-content {
  display: none;
}

.think-tokens-container.collapsed .think-tokens-header {
  border-bottom: none;
}

.main-response {
  margin-top: 0.5em;
}

/* Ensure think tokens content inherits proper styling */
.think-tokens-content h1,
.think-tokens-content h2,
.think-tokens-content h3,
.think-tokens-content h4,
.think-tokens-content h5,
.think-tokens-content h6 {
  margin: 0.5em 0 0.3em 0;
  color: inherit;
  font-weight: bold;
}

.think-tokens-content p {
  margin: 0.5em 0;
  line-height: 1.4;
}

.think-tokens-content ul,
.think-tokens-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.think-tokens-content li {
  margin: 0.2em 0;
}

.think-tokens-content blockquote {
  margin: 0.5em 0;
  padding: 0.5em 1em;
  border-left: 3px solid #ccc;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
  font-style: italic;
}

.think-tokens-content code {
  background: rgba(0,0,0,0.1);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
}

.think-tokens-content pre {
  background: rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 6px;
  padding: 1em;
  margin: 0.5em 0;
  overflow-x: auto;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  line-height: 1.4;
}

.think-tokens-content pre code {
  background: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  font-size: inherit;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Error banner styles */
.error-banner {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--danger-primary);
  color: #fff;
  padding: 0.6em 1.2em;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10000;
  font-weight: 600;
  white-space: pre-line;
  display: none;
  animation: fadeIn 0.2s ease;
  align-items: center;
}

/* FastFlowLM notice styles */
.flm-notice {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
  border: 1px solid #ffeaa7;
  border-left: 4px solid #f39c12;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(243, 156, 18, 0.1);
  animation: fadeIn 0.3s ease;
}

.flm-notice-content {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
}

.flm-notice-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.flm-notice-text {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #856404;
}

.flm-notice-text strong {
  color: #6c5ce7;
  font-weight: 600;
}

.flm-notice-text a {
  color: var(--info-primary);
  text-decoration: none;
  font-weight: 500;
}

.flm-notice-text a:hover {
  text-decoration: underline;
  color: var(--info-hover);
}

.error-banner .close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2em;
  margin-left: 0.8em;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.error-banner .close-btn:hover {
  opacity: 0.8;
}

/* Migration banner - reuses error-banner structure with warning color */
.migration-banner {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #ffa500;
  color: #222;
  padding: 0.6em 1.2em;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10000;
  font-weight: 600;
  display: none;
  animation: fadeIn 0.2s ease;
  align-items: center;
  gap: 0.8em;
}

.migration-action-btn {
  background: #222;
  color: #ffa500;
  border: none;
  padding: 0.4em 0.8em;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.migration-action-btn:hover {
  background: #444;
}

.migration-banner .close-btn {
  background: none;
  border: none;
  color: #222;
  font-size: 1.2em;
  margin-left: 0.8em;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

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

.modal-content {
  background: #fff;
  border-radius: 8px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  padding: 0;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.migration-model-list {
  margin: 1rem 0;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.migration-model-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
}

.migration-model-item:last-child {
  border-bottom: none;
}

.migration-summary {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 4px;
  text-align: center;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.delete-btn {
  padding: 0.6em 1.5em;
  background: var(--danger-primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.delete-btn:hover {
  background: var(--danger-hover);
}

/* === Model Settings === */
.model-settings-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
}

.settings-form {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.setting-row label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.setting-row input {
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color var(--transition-fast);
}

.setting-row input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(230, 184, 0, 0.2);
}

.setting-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.setting-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  justify-content: flex-end;
}

.save-btn {
  padding: 0.75rem 1.5rem;
  background: var(--accent-gold);
  color: #222;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.save-btn:hover {
  background: var(--accent-gold-dark);
}

.reset-btn {
  padding: 0.75rem 1.5rem;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.reset-btn:hover {
  background: #5a6268;
}

/* === Model Browser === */
.model-browser-container {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 600px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  overflow: visible;
}

.model-browser-sidebar {
  width: 280px;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
}

.model-category {
  border-bottom: 1px solid #e0e0e0;
}

.model-category-section {
  border-bottom: 1px solid #e0e0e0;
  padding: 0.5rem 0;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-weight: 600;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: #6c757d;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.category-header:hover {
  background: #e9ecef;
}

.category-header.active {
  background: var(--primary-yellow);
  color: #333;
  font-weight: 600;
}

.category-icon, .section-icon {
  font-size: 1.1rem;
}

.category-name, .section-name {
  flex: 1;
}

.category-content {
  display: none;
}

.category-content.expanded {
  display: block;
}

.section-content {
  padding: 0;
}

.subcategory {
  padding: 0.75rem 1rem 0.75rem 3rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid #f0f0f0;
}

.subcategory:hover {
  background: #e9ecef;
}

.subcategory.active {
  background: var(--primary-yellow);
  color: #333;
  font-weight: 600;
}

/* Add Model Form in Main Area */
.add-model-form-main {
  padding: 1.5rem;
  max-width: 100%;
  box-sizing: border-box;
}

.add-model-form-main .form-content {
  max-width: 800px;
  width: 100%;
}

.add-model-form-main .register-form-row {
  display: flex;
  align-items: center;
  gap: 1.2em;
  margin-bottom: 1em;
  padding: 0.1em 0;
  position: relative;
  max-width: 100%;
  box-sizing: border-box;
}

.add-model-form-main .register-model-name-group {
  display: flex;
  align-items: stretch;
  flex: 1;
  border-radius: 6px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
  min-width: 0;
  max-width: 400px;
}

.add-model-form-main input[type="text"],
.add-model-form-main select {
  max-width: 400px;
  width: 100%;
  box-sizing: border-box;
}

.add-model-form-main #register-checkpoint {
  max-width: 500px;
}

.model-browser-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.model-browser-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
}

.model-browser-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.3rem;
}

.model-list {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  background: #fff;
  transition: all var(--transition-fast);
}

.model-item:hover {
  border-color: var(--accent-gold);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.model-item-info {
  flex: 1;
}

.model-item-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.model-item-description {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.model-item-actions {
  display: flex;
  gap: 0.5rem;
}

/* Modern emoji button styling with clean glass effect */
.model-item-btn {
  position: relative;
  border: none;
  border-radius: 12px;
  padding: 0.75em;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1.3em;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.6));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  color: #555;
  text-align: center;
  overflow: hidden;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", "EmojiSymbols", sans-serif;
}

/* Elegant hover animation with subtle scaling */
.model-item-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.15),
    0 3px 10px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8));
  border-color: rgba(255, 255, 255, 0.5);
}

/* Satisfying active state */
.model-item-btn:active {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 
    0 3px 12px rgba(0, 0, 0, 0.12),
    0 1px 5px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Disabled state with reduced opacity */
.model-item-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: 
    0 1px 3px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  background: linear-gradient(145deg, rgba(248, 248, 248, 0.8), rgba(240, 240, 240, 0.6)) !important;
}

/* Special styling for loading/installing state with enhanced design */
.model-item-btn.loading,
.model-item-btn.installing {
  font-size: 0.75em;
  padding: 0.5em 0.8em;
  width: auto;
  min-width: 90px;
  height: 40px;
  background: linear-gradient(145deg, rgba(107, 114, 128, 0.15), rgba(107, 114, 128, 0.08));
  color: var(--neutral-primary);
  border: 1px solid rgba(107, 114, 128, 0.3);
  cursor: wait;
  backdrop-filter: blur(8px);
  box-shadow: 
    0 2px 8px rgba(107, 114, 128, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-weight: 500;
  white-space: nowrap;
}

/* Pulsing animation for loading states */
.model-item-btn.loading,
.model-item-btn.installing {
  animation: gentle-pulse 2s ease-in-out infinite;
}

@keyframes gentle-pulse {
  0%, 100% { 
    opacity: 1;
    transform: scale(1);
  }
  50% { 
    opacity: 0.8;
    transform: scale(1.02);
  }
}

/* Color-coded hover effects for different action types */
.model-item-btn.install:hover {
  background: linear-gradient(145deg, rgba(230, 184, 0, 0.2), rgba(230, 184, 0, 0.1));
  border-color: rgba(230, 184, 0, 0.4);
  box-shadow: 
    0 8px 25px rgba(230, 184, 0, 0.2),
    0 3px 10px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.model-item-btn.load:hover {
  background: linear-gradient(145deg, rgba(45, 127, 71, 0.2), rgba(45, 127, 71, 0.1));
  border-color: rgba(45, 127, 71, 0.4);
  box-shadow: 
    0 8px 25px rgba(45, 127, 71, 0.2),
    0 3px 10px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.model-item-btn.unload:hover {
  background: linear-gradient(145deg, rgba(107, 114, 128, 0.2), rgba(107, 114, 128, 0.1));
  border-color: rgba(107, 114, 128, 0.4);
  box-shadow: 
    0 8px 25px rgba(107, 114, 128, 0.2),
    0 3px 10px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.model-item-btn.delete:hover {
  background: linear-gradient(145deg, rgba(200, 88, 108, 0.2), rgba(200, 88, 108, 0.1));
  border-color: rgba(200, 88, 108, 0.4);
  box-shadow: 
    0 8px 25px rgba(200, 88, 108, 0.2),
    0 3px 10px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}


/* Dropdown styling */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    background-color: transparent;
    border: none;
    font-size: 16px;
    cursor: pointer;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;              /* align to the right edge of the parent */
    left: auto;            /* prevent left alignment */
    top: calc(100% + 1px); /* opens 8px below the button */
    background-color: #ffe76c;
    border-radius: 8px;
    min-width: 140px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.2);
    z-index: 1000;
    overflow: hidden;
}

.dropdown-content a {
    color: black;
    font-size: 12px;   /* smaller font */
    padding: 8px 12px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f6c146;
}

.dropdown:hover .dropdown-content {
    display: block;
}
