:root {
  --bg: #121212;
  --panel: #1a1a1a;
  --panel-hover: #222222;
  --text: #ffffff;
  --text-secondary: #e8e8e8;
  --muted: #999999;
  --accent: linear-gradient(135deg, #ff6e3a 0%, #f97316 100%);
  --accent-color: #f97316;
  --accent-hover: linear-gradient(135deg, #ff8c5a 0%, #fb923c 100%);
  --danger: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  --danger-color: #dc2626;
  --danger-hover: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --ok: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --ok-color: #10b981;
  --ok-hover: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --border: #2a2a2a;
  --border-light: #3a3a3a;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
  --blur-glass: blur(16px);
}

* { 
  box-sizing: border-box; 
}

html {
  scroll-behavior: smooth;
}
/* Style for caption textarea inside cards */

.caption textarea {
  width: 100%;
  min-height: 80px;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: rgba(16, 16, 16, 0.85);
  color: var(--text);
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  padding: 8px 10px;
  resize: none; /* disable manual resize */
  transition: border-color 0.2s, background 0.2s;
  margin: 0;
  outline: none;
  overflow-y: auto;
  max-height: 200px; /* reduced max height, enable scrolling */
  display: block; /* ensure margin auto works */
  flex-shrink: 1; /* allow shrinking to fit container */
  min-width: 0; /* prevent overflow in flex/grid containers */
}

.caption textarea:focus {
  border-color: var(--accent-color);
  background: rgba(16, 16, 16, 0.98);
}
::selection {
  background: rgba(249, 115, 22, 0.3);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(32, 32, 32, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(249, 115, 22, 0.6);
  border-radius: 4px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(249, 115, 22, 0.8);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  letter-spacing: -0.01em;
  font-feature-settings: "liga", "kern";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

header, footer {
  padding: 20px 32px;
  background: rgba(32, 32, 32, 0.95);
  backdrop-filter: var(--blur-glass);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(249, 115, 22, 0.5) 50%, transparent 100%);
  opacity: 0.8;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header .header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-family: 'Georgia', 'Times New Roman', 'Tiempos Text', 'Charter', serif;
}

header .subtitle {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.02em;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

header .profile-link {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

header .profile-link:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
}

header .profile-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@supports (-webkit-background-clip: text) {
  header h1 {
    background: linear-gradient(135deg, var(--text) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

@supports (background-clip: text) {
  header h1 {
    background: linear-gradient(135deg, var(--text) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

footer { 
  border-top: 1px solid var(--border); 
  border-bottom: none; 
  background: rgba(32, 32, 32, 0.8);
}

footer a {
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-family: 'Georgia', 'Times New Roman', 'Tiempos Text', 'Charter', serif;
}

footer a:hover {
  color: var(--accent-color);
  text-shadow: 0 0 8px rgba(249, 115, 22, 0.3);
}

footer .separator {
  color: var(--muted);
  margin: 0 12px;
  opacity: 0.6;
}

main { 
  padding: 32px; 
  max-width: 1400px;
  margin: 0 auto;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  background: rgba(26, 26, 26, 0.9);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.controls::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(249, 115, 22, 0.3) 50%, transparent 100%);
}

.controls:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
  border-color: var(--border-light);
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

label { 
  color: var(--text-secondary); 
  font-size: 15px; 
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  background: rgba(16, 16, 16, 0.8);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1), var(--shadow);
  background: rgba(16, 16, 16, 0.95);
}

input[type="text"]:hover, input[type="password"]:hover, input[type="number"]:hover, textarea:hover, select:hover {
  border-color: var(--border-light);
  background: rgba(16, 16, 16, 0.9);
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
}

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.buttons { 
  display: flex; 
  gap: 16px; 
  flex-wrap: wrap;
}

.oauth-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-direction: column;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 9999px;
  background: rgba(32, 32, 32, 0.6);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.badge.ok {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.hidden { display: none !important; }

button {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

button:hover::before {
  left: 100%;
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow);
}

button[disabled] { 
  opacity: 0.5; 
  cursor: not-allowed; 
  transform: none;
  background: #3a3a3a;
  color: var(--muted);
}

button[disabled]:hover {
  transform: none;
  box-shadow: var(--shadow);
}

button#btnCancel { 
  background: var(--danger); 
  color: #ffffff; 
}

button#btnCancel:hover { 
  background: var(--danger-hover); 
}

button#btnClear { 
  background: linear-gradient(135deg, #2a2a2a 0%, #3a3a3a 100%); 
  color: var(--text); 
}

button#btnClear:hover { 
  background: linear-gradient(135deg, #3a3a3a 0%, #4a4a4a 100%); 
}

.hint { 
  color: var(--muted); 
  font-size: 12px; 
  line-height: 1.4;
  opacity: 0.8;
}
.preset-row { 
  display: grid; 
  grid-template-columns: 1fr 1fr auto auto; 
  gap: 12px; 
  align-items: end;
}

/* File input styling */
input[type="file"] {
  background: rgba(16, 16, 16, 0.8);
  color: var(--text);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  font-size: 14px;
  transition: all 0.2s ease;
  cursor: pointer;
  text-align: center;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

input[type="file"]:hover {
  border-color: var(--accent-color);
  background: rgba(16, 16, 16, 0.9);
  border-style: solid;
}

input[type="file"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

input[type="file"].processing {
  border-color: var(--accent-color);
  background: rgba(16, 16, 16, 0.9);
  border-style: solid;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

input[type="file"].processing::after {
  content: 'Processing files...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(249, 115, 22, 0.1);
  color: var(--accent-color);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(249, 115, 22, 0.3);
  backdrop-filter: blur(8px);
}

/* Grid improvements */
.grid-3 { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
  gap: 16px; 
}

@media (max-width: 768px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }
  
  .preset-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .buttons {
    flex-direction: column;
  }
  
  main {
    padding: 16px;
  }
  
  .controls {
    padding: 20px;
  }
  
  header, footer {
    padding: 16px 20px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  header .subtitle {
    font-size: 0.75rem;
  }

  header .profile-link {
    width: 40px;
    height: 40px;
  }

  /* Fix text overflow issues on mobile */
  .custom-options-header {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .custom-select-trigger {
    font-size: 13px;
    padding: 12px 14px;
  }

  .custom-select-trigger span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 20px);
  }

  .custom-option .model-name {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .custom-option .model-provider {
    font-size: 11px;
  }

  .results {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .media {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .media .left {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .meta .meta-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 8px;
  }

  .caption {
    font-size: 13px;
    padding: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }
  
  .caption textarea {
    max-width: 100%;
    width: 100%;
  }

  .meta {
    font-size: 11px;
    padding: 10px 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .oauth-row {
    gap: 8px;
  }

  .controls input[type="text"],
  .controls input[type="password"],
  .controls input[type="number"],
  .controls input[type="file"],
  .controls textarea,
  .controls select,
  .controls button {
    width: 100%;
    max-width: 100%;
  }

  .controls button {
    padding-left: 16px;
    padding-right: 16px;
  }

  progress {
    width: 100%;
    max-width: 280px;
  }

  .status {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }

  /* Ensure long text doesn't break layout */
  * {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Prevent horizontal scrolling */
  body {
    overflow-x: hidden;
  }

  .controls, .card {
    max-width: 100vw;
    box-sizing: border-box;
  }
}

.custom-select-wrapper { 
  position: relative; 
}

.custom-select { 
  position: relative; 
}

.custom-select-trigger {
  background: rgba(16, 16, 16, 0.8);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  font-size: 14px;
  font-family: 'Georgia', 'Times New Roman', 'Tiempos Text', 'Charter', serif;
}

.custom-select-trigger:hover {
  border-color: var(--border-light);
  background: rgba(16, 16, 16, 0.9);
}
.arrow {
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--muted);
  transition: all 0.3s ease;
}

.custom-select.open .arrow { 
  transform: rotate(180deg); 
  border-top-color: var(--accent-color);
}

.custom-options {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 10;
  max-height: 320px;
  overflow-y: hidden;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.custom-select.open .custom-options { 
  display: flex; 
}

.custom-options-header {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(32, 32, 32, 0.5);
}

.custom-options-header input,
.custom-options-header select {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
}

.custom-options-header input[type="checkbox"] {
  width: auto;
}

.custom-options-header .model-filter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.model-options-list {
  overflow-y: auto;
  max-height: 240px;
}

.custom-option {
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.custom-option:hover { 
  background-color: rgba(32, 32, 32, 0.8);
  border-left-color: var(--accent-color);
}

.custom-option.selected { 
  background-color: rgba(249, 115, 22, 0.1);
  border-left-color: var(--accent-color);
}

.custom-option .model-name { 
  font-weight: 600; 
  margin-bottom: 2px;
  font-family: 'Georgia', 'Times New Roman', 'Tiempos Text', 'Charter', serif;
}

.custom-option .model-provider { 
  color: var(--muted); 
  font-size: 12px; 
  opacity: 0.8;
}

.status { 
  margin: 24px 0; 
  display: flex; 
  align-items: center; 
  gap: 16px; 
  padding: 16px 20px;
  background: rgba(26, 26, 26, 0.6);
  border-radius: 12px;
  border: 1px solid var(--border);
}

progress {
  width: min(100%, 320px);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(32, 32, 32, 0.8);
  border: none;
}

progress::-webkit-progress-bar {
  background: rgba(32, 32, 32, 0.8);
  border-radius: 4px;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 4px;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.card {
  background: rgba(26, 26, 26, 0.9);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: grid;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
  position: relative;
  min-width: 0; /* allow grid item to shrink */
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(249, 115, 22, 0.2) 50%, transparent 100%);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--border-light);
}
.media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 200px;
}

.media > div { 
  padding: 16px; 
  display: grid; 
  align-content: start; 
  gap: 12px; 
  overflow: hidden; /* prevent content from overflowing */
  min-width: 0; /* allow grid items to shrink below content size */
}

.media .left { 
  border-right: 1px solid var(--border); 
  background: rgba(16, 16, 16, 0.3);
}

.media img, .media video, .media canvas { 
  max-width: 100%; 
  border-radius: 8px; 
  background: #000; 
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.media img:hover, .media video:hover, .media canvas:hover {
  transform: scale(1.02);
}

.caption { 
  padding: 8px; 
  font-size: 14px; 
  line-height: 1.6; 
  white-space: pre-wrap; 
  background: rgba(16, 16, 16, 0.2);
  margin: 0;
  color: var(--text-secondary);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden; /* prevent overflow */
  min-width: 0; /* allow flexbox item to shrink */
  width: 100%; /* take full available width */
}

.meta { 
  color: var(--muted); 
  font-size: 12px; 
  padding: 12px 16px; 
  border-top: 1px dashed rgba(32, 32, 32, 0.6); 
  background: rgba(32, 32, 32, 0.2);
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  align-items: center;
  gap: 0;
}

.meta .meta-left {
  border-right: 1px solid var(--border);
  padding-right: 16px;
  min-width: 0; /* allow truncation */
}

.meta .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.meta .meta-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
}

.meta .meta-right button {
  padding: 8px 12px;
  font-size: 12px;
  min-width: auto;
}

.icon-btn {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
}

.icon-btn:hover {
  background: rgba(32, 32, 32, 0.4);
  color: var(--text);
  transform: translateY(0);
  box-shadow: none;
}

.icon-btn:active {
  background: rgba(32, 32, 32, 0.6);
}

.error { 
  color: #fca5a5; 
  background: rgba(220, 38, 38, 0.1);
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--danger-color);
}

.ok { 
  color: #6ee7b7; 
  background: rgba(16, 185, 129, 0.1);
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--ok-color);
}

/* Loading animation */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Focus visible for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Smooth focus transitions */
*:focus {
  transition: outline 0.2s ease, box-shadow 0.2s ease;
}

/* Enhanced button group spacing */
.buttons button {
  min-width: 120px;
  justify-content: center;
}

/* Status text styling */
#progressText {
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 100px;
  transition: color 0.3s ease;
}

#progressText.processing {
  color: var(--accent-color);
}

#progressText.error {
  color: var(--danger-color);
}

#progressText.success {
  color: var(--ok-color);
}

/* Improved card animations */
@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: cardSlideIn 0.4s ease-out;
}

/* Enhanced glass effect for modern browsers */
@supports (backdrop-filter: blur(16px)) {
  .controls,
  .card,
  header,
  footer {
    backdrop-filter: var(--blur-glass);
  }
}

/* Advanced Section Styling */
.advanced-section {
  background: rgba(16, 16, 16, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  margin: 8px 0;
}

.advanced-section summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  list-style: none;
  user-select: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.advanced-section summary::-webkit-details-marker {
  display: none;
}

.advanced-section summary::before {
  content: '▶';
  display: inline-block;
  transition: transform 0.3s ease;
  color: var(--muted);
  font-size: 12px;
}

.advanced-section[open] summary::before {
  transform: rotate(90deg);
}

.advanced-section summary:hover {
  color: var(--accent-color);
  background: rgba(32, 32, 32, 0.3);
}

.advanced-content {
  padding: 0;
  display: grid;
  gap: 16px;
  border-top: 1px solid var(--border);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: all 0.3s ease;
}

.advanced-section[open] .advanced-content {
  padding: 16px;
  max-height: 500px;
  opacity: 1;
}

/* Toggle Switch Styling */
.reasoning-field {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-direction: row !important;
  gap: 12px;
}

.reasoning-field > label:last-child {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  text-transform: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  margin: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(32, 32, 32, 0.8);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: all 0.3s ease;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent-color);
}

.switch input:checked + .slider:before {
  transform: translateX(22px);
  background-color: #ffffff;
}

.switch input:focus + .slider {
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.slider:hover {
  border-color: var(--border-light);
}

.mode-switch {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-switch > label:last-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.mode-switch .mode-description {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: normal;
}

.mode-switch #modeLabel {
  font-weight: 500;
  color: var(--text-primary);
}

.image-pair-container {
  display: flex;
  gap: 8px;
  width: 100%;
}

.image-pair-container img {
  flex: 1;
  max-width: 50%;
  border-radius: 8px;
  object-fit: cover;
}

/* VLLM Custom Server Styling */
#customVllmEndpoint {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-weight: 500;
  letter-spacing: 0.5px;
}

#customVllmEndpoint:invalid {
  border-color: var(--danger-color);
  background: rgba(220, 38, 38, 0.05);
}

#customVllmEndpoint:invalid:focus {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* VLLM Connection Status Indicator */
.vllm-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
}

.vllm-status-indicator.error {
  color: var(--danger-color);
}

.vllm-status-indicator.success {
  color: var(--ok-color);
}

.vllm-status-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.vllm-status-indicator.error::before {
  background: var(--danger-color);
  box-shadow: 0 0 4px var(--danger-color);
  animation: pulse-error 2s infinite;
}

.vllm-status-indicator.success::before {
  background: var(--ok-color);
  box-shadow: 0 0 4px var(--ok-color);
}

@keyframes pulse-error {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

/* Tooltip for VLLM status */
.vllm-tooltip {
  position: relative;
  display: inline-block;
}

.vllm-tooltip .vllm-tooltip-text {
  visibility: hidden;
  width: 200px;
  background-color: rgba(26, 26, 26, 0.95);
  color: var(--text);
  text-align: center;
  border-radius: 6px;
  padding: 8px 12px;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 12px;
  border: 1px solid var(--border);
  backdrop-filter: var(--blur-glass);
  box-shadow: var(--shadow-lg);
}

.vllm-tooltip .vllm-tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: rgba(26, 26, 26, 0.95) transparent transparent transparent;
}

.vllm-tooltip:hover .vllm-tooltip-text {
  visibility: visible;
  opacity: 1;
}

