:root {
  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --text-primary: #e6e6e6;
  --text-secondary: #a0a0a0;
  --accent: #00d4aa;
  --accent-hover: #00b894;
  --border: #2d3748;
  --error: #e53e3e;
  --warning: #ed8936;
  --success: #38a169;
  --code-bg: #1a202c;
  --message-user: #2d3748;
  --message-assistant: #1a202c;
  --thought-bg: #282c3a; /* Slightly different background for thought */
  --thought-border: #3a4051;
  --thought-text: var(--text-secondary);
}
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f7fafc;
  --bg-tertiary: #edf2f7;
  --text-primary: #2d3748;
  --text-secondary: #4a5568;
  --accent: #00a085;
  --accent-hover: #00785e;
  --border: #e2e8f0;
  --code-bg: #f7fafc;
  --message-user: #e2e8f0;
  --message-assistant: #f7fafc;
  --thought-bg: #e9ecef;
  --thought-border: #dee2e6;
  --thought-text: var(--text-secondary);
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}
.header {
  background: var(--bg-secondary);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo i {
  font-size: 24px;
}
.model-selector {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 14px;
  min-width: 200px;
  cursor: pointer;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-radius: 20px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  animation: pulse 2s infinite;
}
.status-dot.online {
  background: var(--success);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.header-buttons {
  display: flex;
  gap: 8px;
}
.header-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-btn:hover {
  background: var(--accent);
  color: white;
}
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}
.message {
  display: flex;
  margin-bottom: 20px;
  max-width: 100%;
  animation: messageSlide 0.3s ease-out;
}
@keyframes messageSlide {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.user {
  justify-content: flex-end;
}
.message-content {
  max-width: 70%;
  min-width: 200px;
}
.message.user .message-content {
  background: var(--message-user);
  border-radius: 18px 18px 4px 18px;
  padding: 12px 16px;
  margin-left: 48px;
}
.message.assistant .message-content {
  background: var(--message-assistant);
  border-radius: 18px 18px 18px 4px;
  padding: 14px;
  margin-right: 48px;
  border: 1px solid var(--border);
  display: flex; /* Use flexbox to stack content and thought */
  flex-direction: column;
  position: relative; /* Add position for response actions */
}
.message-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.message.assistant:hover .message-actions {
  opacity: 1;
}
.message-action-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.2s ease;
}
.message-action-btn:hover {
  background: var(--accent);
  color: white;
}
.message-action-btn.copied {
  background: var(--success);
  color: white;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  font-size: 14px;
  margin: 0 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.message.user .avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  order: 2;
}
.message.assistant .avatar {
  background: linear-gradient(135deg, var(--accent) 0%, #00b894 100%);
}
.text {
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding-bottom: 8px; /* Add padding below main text */
  border-bottom: 1px solid transparent; /* Add border below text if thought exists */
  margin-bottom: 8px; /* Add margin below text if thought exists */
}
.message.assistant .message-content .text:not(:last-child) {
   border-bottom-color: var(--border);
}

/* Thought Section Styling */
.thought-container {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--thought-text);
    order: -1;
}

.thought-toggle {
    background: none;
    border: none;
    color: var(--thought-text);
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s ease;
    margin-bottom: 8px;
}

.thought-toggle:hover {
    color: var(--text-primary);
}

.thought-toggle i {
    transition: transform 0.2s ease;
    font-size: 10px;
}

.thought-container.expanded .thought-toggle i {
    transform: rotate(180deg);
}

.thought-content {
    height: 0;
    overflow: hidden;
    opacity: 0;
    transition: height 0.3s ease-in-out, opacity 0.3s ease-out;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
}

.thought-container.expanded .thought-content {
    height: auto;
    opacity: 1;
    padding: 12px;
    background: var(--thought-bg);
    border-radius: 6px;
    margin-top: 8px;
    overflow: visible;
    min-height: min-content;
}
/* End Thought Section Styling */

/* Streaming cursor animation */
.streaming-cursor {
  color: var(--accent);
  font-weight: bold;
  margin-left: 2px;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.code-container {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 8px 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: relative;
}
.code-header {
  background: var(--bg-tertiary);
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  height: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.code-lang {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  font-size: 10px;
}
.code-lang:before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.code-lang.language-html:before {
  background: #e34c26;
}
.code-lang.language-css:before {
  background: #264de4;
}
.code-lang.language-js:before,
.code-lang.language-javascript:before {
  background: #f7df1e;
}
.code-lang.language-python:before {
  background: #306998;
}
.code-lang.language-php:before {
  background: #777BB3;
}
.code-actions {
  display: flex;
  gap: 6px;
  height: 100%;
  align-items: center;
}
.code-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  min-width: 24px;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.code-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transform: none;
}
.code-btn i {
  font-size: 12px;
}
.code-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  z-index: 100;
}
.code-btn:hover::after {
  opacity: 1;
  visibility: visible;
  bottom: -28px;
}
.code-btn.run-btn:hover {
  color: var(--accent);
}
.code-btn.preview-btn:hover {
  color: #6366f1;
}
.code-btn.download-btn:hover {
  color: var(--warning);
}
.code-btn.copied {
  color: var(--success);
}
.code-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.code-content {
  position: relative;
  max-height: 500px;
  overflow-y: auto;
  background: var(--bg-primary); /* Changed background to be darker/lighter */
}
.code-content pre {
  margin: 0;
  padding: 12px 16px;
  overflow-x: auto;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.5;
}
.output {
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  font-family: monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}
.output.success {
  border-left: 4px solid var(--success);
}
.output.error {
  border-left: 4px solid var(--error);
  color: var(--error);
}
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-style: italic;
  margin-left: 48px;
}
.typing-dots {
  display: flex;
  gap: 2px;
}
.typing-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}
.input-area {
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}
.input-wrapper {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}
.input {
  width: 100%;
  padding: 16px 120px 16px 20px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: 24px;
  color: var(--text-primary);
  font-size: 15px;
  resize: none;
  min-height: 56px;
  max-height: 200px;
  transition: all 0.2s ease;
  font-family: inherit;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}
.input:disabled {
  opacity: 0.6;
}
.input-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 8px;
}
.action-btn {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
}
.action-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}
.action-btn:disabled {
  background: var(--border);
  cursor: not-allowed;
  transform: none;
}
.sidebar {
  position: fixed;
  left: -300px;
  top: 0;
  width: 300px;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  transition: left 0.3s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
.sidebar.open {
  left: 0;
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.chat-history-item {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
}
.chat-history-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.chat-history-actions {
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  gap: 4px;
}
.chat-history-item:hover .chat-history-actions {
  opacity: 1;
}
.chat-history-action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
}
.chat-history-action-btn:hover {
  color: var(--error);
}
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: center;
}
.sidebar-btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-btn:hover {
  background: var(--accent-hover);
}
.danger {
  background: #e53e3e;
}
.danger:hover {
  background: #d32d2d;
}
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.overlay.show {
  opacity: 1;
  pointer-events: all;
}
.preview-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 1100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  resize: both;
}
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 49px;
}
.preview-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.preview-content {
  flex: 1;
  position: relative;
  height: calc(100% - 49px);
  overflow: hidden;
}
.preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
  display: block;
}
.preview-window .resize-handle {
  position: absolute;
  background: transparent;
}
.preview-window .resize-handle.top {
  top: 0;
  left: 15px;
  right: 15px;
  height: 8px;
  cursor: ns-resize;
}
.preview-window .resize-handle.right {
  top: 15px;
  right: 0;
  bottom: 15px;
  width: 8px;
  cursor: ew-resize;
}
.preview-window .resize-handle.bottom {
  bottom: 0;
  left: 15px;
  right: 15px;
  height: 8px;
  cursor: ns-resize;
}
.preview-window .resize-handle.left {
  top: 15px;
  left: 0;
  bottom: 15px;
  width: 8px;
  cursor: ew-resize;
}
.preview-window .resize-handle.top-left {
  top: 0;
  left: 0;
  width: 15px;
  height: 15px;
  cursor: nwse-resize;
}
.preview-window .resize-handle.top-right {
  top: 0;
  right: 0;
  width: 15px;
  height: 15px;
  cursor: nesw-resize;
}
.preview-window .resize-handle.bottom-left {
  bottom: 0;
  left: 0;
  width: 15px;
  height: 15px;
  cursor: nesw-resize;
}
.preview-window .resize-handle.bottom-right {
  bottom: 0;
  right: 0;
  width: 15px;
  height: 15px;
  cursor: nwse-resize;
}
.preview-window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
  border-radius: 0;
  transition: all 0.3s ease;
}
.katex-display {
  margin: 1em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-top: 0.5em;
  padding-bottom: 0.5em;
}
.katex {
  font-size: 1.1em;
}
.katex-inline {
  display: inline-block;
  padding: 0 0.2em;
}
.math-display {
  display: block;
  width: 100%;
  overflow-x: auto;
  margin: 1em 0;
  padding: 1em;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
}
.math-display .katex-display {
  margin: 0;
}
.katex {
  font-size: 1.1em;
  text-align: center;
}
.katex .boxed {
  border: 1px solid currentColor;
  padding: 0.2em 0.5em;
  border-radius: 2px;
}
/* Model Library Styles */
.model-library-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.95em;
}

.quick-download {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 32px;
  color: white;
  text-align: center;
}

.quick-download-header h3 {
  margin: 0 0 8px 0;
  font-size: 1.2em;
  color: white;
}

.quick-download-header p {
  margin: 0 0 16px 0;
  opacity: 0.9;
  font-size: 0.9em;
}

.quick-start-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 12px 24px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.quick-start-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.models-section {
  margin-top: 32px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.1em;
}

.model-count {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 500;
}

.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.model-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.model-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: var(--accent);
}

.model-card.installed {
  border-color: var(--success);
  background: linear-gradient(135deg, var(--bg-primary), rgba(56, 161, 105, 0.05));
}

.model-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.model-header h4 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.1em;
  font-weight: 600;
}

.installed-badge {
  background: var(--success);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.model-specs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.9em;
}

.spec-item i {
  width: 16px;
  color: var(--accent);
}

.model-actions {
  margin-top: auto;
}

.chat-btn, .downloadmdlbtn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.chat-btn {
  background: var(--success);
  color: white;
}

.chat-btn:hover {
  background: #2f855a;
  transform: translateY(-1px);
}

.downloadmdlbtn {
  background: var(--accent);
  color: white;
}

.downloadmdlbtn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

/* Preserve the existing download-btn class for code block download buttons */
.code-btn.download-btn:hover {
  color: var(--warning);
}
.popup-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Download Dialog Styles */
.download-dialog {
  max-width: 600px;
  width: 90%;
}

.download-header {
  text-align: center;
  margin-bottom: 24px;
}

.download-subtitle {
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-top: 8px;
}

.download-status-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.status-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent);
  background: rgba(0, 212, 170, 0.1);
  border-radius: 12px;
}

.status-icon i.rotating {
  animation: rotating 2s linear infinite;
}

@keyframes rotating {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.status-text {
  flex: 1;
}

.status-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.status-detail {
  font-size: 0.85em;
  color: var(--text-secondary);
}

.progress-bar-container {
  margin: 20px 0;
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: right;
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-top: 6px;
}

.download-log {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 20px;
  max-height: 180px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.log-header {
  background: var(--bg-secondary);
  padding: 8px 12px;
  font-size: 0.85em;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.log-content {
  padding: 10px;
  font-family: monospace;
  font-size: 12px;
  overflow-y: auto;
  max-height: 150px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.log-entry {
  margin-bottom: 6px;
  line-height: 1.4;
}

.download-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  gap: 12px;
}

.primary-btn, .secondary-btn {
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  font-size: 14px;
}

.primary-btn {
  background: var(--accent);
  color: white;
}

.primary-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.secondary-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.secondary-btn:hover {
  background: var(--bg-secondary);
}

/* Success Animation */
.download-success {
  text-align: center;
  padding: 24px;
}

.success-animation {
  font-size: 64px;
  color: var(--success);
  margin: 24px 0;
  animation: success-pulse 1.5s ease-in-out;
}

@keyframes success-pulse {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.success-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

/* Popup Overlay Styles */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px);
}

.popup-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  padding: 30px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: popupFadeIn 0.3s ease-out;
}

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

.popup-content h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
}

.popup-content p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.popup-content ol {
  margin: 0 0 30px 20px;
  padding: 0;
}

.popup-content li {
  margin-bottom: 10px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.popup-content a {
  color: var(--accent);
  text-decoration: none;
  transition: all 0.2s ease;
}

.popup-content a:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.close-popup-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.close-popup-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
  transform: rotate(90deg);
}

/* ========== MODEL MANAGER (dl.php) STYLES ========== */

/* Main Content Layout */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

/* Tab Navigation */
.tabs {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 16px 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  position: relative;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-primary);
}

.tab i {
  font-size: 16px;
}

/* Tab Content */
.tab-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-pane {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  animation: fadeIn 0.3s ease-in-out;
}

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

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

/* Alert System */
#alerts {
  position: sticky;
  top: 0;
  z-index: 100;
  margin-bottom: 16px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 16px;
  border-left: 4px solid;
  background: var(--bg-tertiary);
  animation: slideDown 0.3s ease-out;
  position: relative;
}

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

.alert-success {
  border-left-color: var(--success);
  background: rgba(56, 161, 105, 0.1);
}

.alert-error {
  border-left-color: var(--error);
  background: rgba(229, 62, 62, 0.1);
}

.alert-info {
  border-left-color: var(--accent);
  background: rgba(0, 212, 170, 0.1);
}

.alert-warning {
  border-left-color: var(--warning);
  background: rgba(237, 137, 54, 0.1);
}

.alert i {
  color: inherit;
  font-size: 16px;
  margin-top: 2px;
}

.alert span {
  flex: 1;
  line-height: 1.4;
}

.alert .close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.alert .close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

/* Enhanced Alert Styles for Installation Instructions */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 16px;
  border-left: 4px solid;
  background: var(--bg-tertiary);
  animation: slideDown 0.3s ease-out;
  position: relative;
}

.alert-warning {
  border-left-color: var(--warning);
  background: rgba(237, 137, 54, 0.1);
}

.alert-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.alert-header i {
  font-size: 24px;
  color: inherit;
}

.alert-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-primary);
}

.installation-steps {
  margin: 20px 0;
}

.installation-steps h4 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 16px;
}

.installation-steps ol {
  margin: 0 0 0 20px;
  padding: 0;
}

.installation-steps li {
  margin-bottom: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.installation-steps code {
  background: var(--bg-primary);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  border: 1px solid var(--border);
}

.quick-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.technical-details {
  margin-top: 16px;
  font-size: 13px;
}

.technical-details details {
  cursor: pointer;
}

.technical-details summary {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 8px 0;
  user-select: none;
}

.technical-details summary:hover {
  color: var(--text-primary);
}

.technical-details p {
  margin: 8px 0 0 16px;
  color: var(--text-secondary);
  font-family: monospace;
  font-size: 12px;
  background: var(--bg-primary);
  padding: 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Command Instructions Popup */
.command-box {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  position: relative;
  font-family: 'Fira Code', monospace;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.command-box code {
  background: none;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  border: none;
  padding: 0;
}

.copy-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.copy-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.command-instructions {
  margin: 20px 0;
}

.command-instructions h4 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 16px;
}

.command-instructions ol {
  margin: 0 0 0 20px;
  padding: 0;
}

.command-instructions li {
  margin-bottom: 8px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.popup-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* Close button for enhanced popups */
.close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
  transform: rotate(90deg);
}

/* Alert notification function support */
.alert-notification {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 1200;
  min-width: 300px;
  max-width: 400px;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from { 
    opacity: 0; 
    transform: translateX(100%); 
  }
  to { 
    opacity: 1; 
    transform: translateX(0); 
  }
}

.alert-notification.fade-out {
  animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideOutRight {
  from { 
    opacity: 1; 
    transform: translateX(0); 
  }
  to { 
    opacity: 0; 
    transform: translateX(100%); 
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .header {
    padding: 12px 16px;
  }
  
  .header-left {
    gap: 12px;
  }
  
  .logo {
    font-size: 18px;
  }
  
  .model-selector {
    min-width: 150px;
    font-size: 13px;
  }
  
  .tabs {
    padding: 0 16px;
  }
  
  .tab {
    padding: 12px 16px;
    font-size: 13px;
  }
  
  .tab-pane {
    padding: 16px;
  }
  
  .search-filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    min-width: auto;
  }
  
  .model-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .available-models {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .model-stats {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .header-left .logo {
    display: none;
  }
  
  .model-selector {
    min-width: 120px;
    font-size: 12px;
  }
  
  .header-buttons {
    gap: 4px;
  }
  
  .header-btn {
    padding: 6px 8px;
    font-size: 12px;
  }
  
  .status {
    font-size: 12px;
    padding: 4px 8px;
  }
  
  .available-model,
  .installed-model-card {
    padding: 16px;
  }
  
  .model-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Print Styles */
@media print {
  .header,
  .tabs,
  .search-filters,
  .progress-container,
  .btn,
  #alerts {
    display: none !important;
  }
  
  .main-content {
    overflow: visible;
  }
  
  .tab-pane {
    display: block !important;
    overflow: visible;
    padding: 0;
  }
  
  .available-model,
  .installed-model-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .available-model,
  .installed-model-card {
    border-width: 2px;
  }
  
  .btn {
    border: 2px solid currentColor;
  }
  
  .progress-fill {
    border: 1px solid currentColor;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .spinner {
    animation: none;
    border: 2px solid var(--accent);
  }
  
  .progress-fill::after {
    animation: none;
  }
}