/* ============================================
   RedSky - Neon Glass Design System
   ============================================ */

/* CSS Variables */
:root {
  /* Backgrounds - layered, not flat black */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a24;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);

  /* Brand gradient (RedSky) */
  --gradient-brand: linear-gradient(135deg, #ff3d3d 0%, #b44dff 100%);
  --color-red: #ff3d3d;
  --color-purple: #b44dff;

  /* Glow effects */
  --glow-brand: 0 0 20px rgba(255, 61, 61, 0.25), 0 0 40px rgba(180, 77, 255, 0.15);
  --glow-purple: 0 0 20px rgba(180, 77, 255, 0.3);
  --glow-red: 0 0 20px rgba(255, 61, 61, 0.3);

  /* Text */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.5);

  /* Glass effect */
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-hover: rgba(255, 255, 255, 0.15);

  /* Status colors */
  --color-success: #22c55e;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;

  /* Spacing & Layout */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --navbar-height: 65px;
}

/* Reset & Base */
* {
  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);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--color-purple);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-red);
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-logo {
  height: 48px;
  width: auto;
}

.nav-brand a {
  display: flex;
  align-items: center;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  text-decoration: none;
}

.nav-link.active {
  color: var(--text-primary);
  background: var(--glass-bg);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-user .username {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Hamburger toggle (hidden on desktop) */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.3s ease;
  position: relative;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 20px;
}

.nav-toggle-icon::before {
  top: -6px;
}

.nav-toggle-icon::after {
  top: 6px;
}

.nav-toggle.open .nav-toggle-icon {
  background: transparent;
}

.nav-toggle.open .nav-toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}

.nav-toggle.open .nav-toggle-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

/* ============================================
   Layout
   ============================================ */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: calc(100vh - var(--navbar-height));
}

.main-content {
  padding: 40px;
  max-width: 800px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 32px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.form-section {
  margin-bottom: 28px;
}

/* ============================================
   Glass Card
   ============================================ */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.3s ease;
}

.glass-card:hover {
  border-color: var(--glass-border-hover);
}

/* ============================================
   Form Elements
   ============================================ */
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.input-field,
.textarea-field,
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: all 0.3s ease;
  resize: vertical;
}

.input-field:focus,
.textarea-field:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-purple);
  box-shadow: 0 0 0 3px rgba(180, 77, 255, 0.15);
}

/* Native <select> dropdown options: force a solid dark background + light text. Without this
   the option list inherits light text on the OS's white popup background, so the whole list
   reads as blank and only the row under the cursor (OS highlight) is visible. */
select option,
select optgroup {
  background-color: #16161f;
  color: var(--text-primary, #e8e8f0);
}

.input-field::placeholder,
.textarea-field::placeholder,
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.form-group small {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--glass-border-hover);
  text-decoration: none;
}

.btn-primary {
  padding: 16px 32px;
  background: var(--gradient-brand);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-brand);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -100%;
  width: 100%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
}

.btn-primary:hover::after {
  left: 100%;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary:disabled::after {
  display: none;
}

.btn-secondary {
  padding: 12px 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--glass-border-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--color-danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--color-danger);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-block {
  display: block;
  width: 100%;
}

/* ============================================
   Model Selector Grid
   ============================================ */
.model-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.model-selector-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  background: var(--glass-bg);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.model-selector-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--glow-brand);
}

.model-selector-card.selected {
  background: linear-gradient(var(--bg-secondary), var(--bg-secondary)) padding-box,
              var(--gradient-brand) border-box;
  border: 2px solid transparent;
  box-shadow: var(--glow-brand);
}

.model-selector-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--glass-border);
  margin-bottom: 10px;
  transition: all 0.3s ease;
}

.model-selector-card:hover .model-selector-avatar,
.model-selector-card.selected .model-selector-avatar {
  border-color: var(--color-purple);
  box-shadow: var(--glow-purple);
}

.model-selector-avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: 10px;
  transition: all 0.3s ease;
}

.model-selector-card:hover .model-selector-avatar-placeholder,
.model-selector-card.selected .model-selector-avatar-placeholder {
  border-color: var(--color-purple);
  box-shadow: var(--glow-purple);
}

.model-selector-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
}

.model-selector-checkmark {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  background: var(--gradient-brand);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
}

.model-selector-card.selected .model-selector-checkmark {
  display: flex;
}

.no-models-message {
  padding: 32px;
  text-align: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

/* ============================================
   Shot Type Selector
   ============================================ */
.shot-type-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.shot-option {
  cursor: pointer;
}

.shot-option input {
  display: none;
}

.shot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.shot-option:hover .shot-card {
  background: var(--bg-card-hover);
  transform: scale(1.02);
}

.shot-option input:checked + .shot-card {
  background: linear-gradient(135deg, rgba(255, 61, 61, 0.1) 0%, rgba(180, 77, 255, 0.1) 100%);
  border-color: var(--color-purple);
  box-shadow: var(--glow-purple);
}

.shot-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  opacity: 0.7;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shot-icon img {
  width: 100%;
  height: 100%;
  filter: brightness(0) invert(1);
  opacity: 0.7;
}

.shot-option:hover .shot-icon,
.shot-option input:checked + .shot-card .shot-icon {
  opacity: 1;
}

.shot-option input:checked + .shot-card .shot-icon img {
  filter: brightness(0) saturate(100%) invert(45%) sepia(85%) saturate(2000%) hue-rotate(310deg) brightness(100%);
  opacity: 1;
}

.shot-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.shot-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   Aspect Ratio Selector
   ============================================ */
.ratio-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.ratio-option {
  cursor: pointer;
}

.ratio-option input {
  display: none;
}

.ratio-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  min-width: 70px;
}

.ratio-option:hover .ratio-card {
  background: var(--bg-card-hover);
}

.ratio-option input:checked + .ratio-card {
  background: linear-gradient(135deg, rgba(255, 61, 61, 0.1) 0%, rgba(180, 77, 255, 0.1) 100%);
  border-color: var(--color-purple);
}

.ratio-icon {
  border: 2px solid var(--text-muted);
  border-radius: 4px;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.ratio-option input:checked + .ratio-card .ratio-icon {
  border-color: var(--color-purple);
  box-shadow: var(--glow-purple);
}

/* Ratio icon sizes */
.ratio-1-1 { width: 28px; height: 28px; }
.ratio-3-4 { width: 24px; height: 32px; }
.ratio-4-3 { width: 32px; height: 24px; }
.ratio-2-3 { width: 22px; height: 32px; }
.ratio-3-2 { width: 32px; height: 22px; }
.ratio-9-16 { width: 18px; height: 32px; }
.ratio-16-9 { width: 36px; height: 20px; }

.ratio-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.ratio-option input:checked + .ratio-card .ratio-label {
  color: var(--text-primary);
}

/* ============================================
   Generation Model Selector (Banana/Seedream)
   ============================================ */
.gen-model-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.gen-model-option {
  cursor: pointer;
}

.gen-model-option input {
  display: none;
}

.gen-model-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.gen-model-option:hover .gen-model-card {
  background: var(--bg-card-hover);
  border-color: var(--glass-border-hover);
}

.gen-model-option input:checked + .gen-model-card {
  background: linear-gradient(135deg, rgba(255, 61, 61, 0.1) 0%, rgba(180, 77, 255, 0.1) 100%);
  border-color: var(--color-purple);
  box-shadow: var(--glow-purple);
}

.gen-model-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.gen-model-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   Sidebar
   ============================================ */
.generate-sidebar {
  background: var(--bg-secondary);
  border-left: 1px solid var(--glass-border);
  padding: 24px;
  height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  position: sticky;
  top: var(--navbar-height);
}

.generate-sidebar h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.recent-item:hover {
  background: var(--glass-bg);
}

.recent-item img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.recent-placeholder {
  width: 44px;
  height: 44px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-muted);
}

.recent-info {
  flex: 1;
  min-width: 0;
}

.recent-prompt {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-date {
  font-size: 11px;
  color: var(--text-muted);
}

.no-recent {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

/* ============================================
   Generate Page
   ============================================ */
.generate-page {
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: calc(100vh - var(--navbar-height));
}

.generate-main {
  padding: 40px;
  max-width: 800px;
  min-width: 0;
}

.prompt-section {
  margin-bottom: 32px;
}

.prompt-section h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 32px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   Result Section
   ============================================ */
.result-section {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 32px;
}

.result-section h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.result-images-row {
  display: flex;
  gap: 16px;
  margin: 16px 0;
}

.result-image-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.result-image-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 2px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.result-image-label.label-clean {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(180, 77, 255, 0.2));
  color: var(--color-success);
}

.result-image-container {
  margin: 8px 0;
  text-align: center;
  width: 100%;
}

.result-image-container img {
  max-width: 100%;
  max-height: 500px;
  border-radius: var(--radius-sm);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.seedream-loading-card {
  justify-content: center;
  min-height: 200px;
}

.seedream-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.seedream-spinner .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--color-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .result-images-row {
    flex-direction: column;
  }
}

.result-info {
  margin: 16px 0;
}

.result-info details {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-md);
}

.result-info summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
}

.result-info pre {
  margin-top: 12px;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--text-muted);
}

.refine-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--glass-border);
}

.refine-section h4 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ============================================
   Error Section
   ============================================ */
.error-section {
  margin-top: 24px;
}

.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.error-message h4 {
  color: var(--color-danger);
  margin-bottom: 12px;
}

.error-message p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  word-break: break-word;
}

/* ============================================
   Flash Messages
   ============================================ */
.flash-messages {
  margin-bottom: 24px;
}

.flash {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: 14px;
}

.flash-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-danger);
}

.flash-success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--color-success);
}

.flash-info {
  background: rgba(180, 77, 255, 0.15);
  border: 1px solid rgba(180, 77, 255, 0.3);
  color: var(--color-purple);
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 48px;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  margin-bottom: 16px;
}

.login-logo img {
  height: 72px;
  width: auto;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-form {
  text-align: left;
}

.login-form .btn-primary {
  margin-top: 8px;
}

/* ============================================
   History Page
   ============================================ */
.history-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.history-header h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.history-count {
  color: var(--text-muted);
  font-size: 14px;
}

/* Filters Panel */
.filters-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 150px;
}

.filter-group.filter-search {
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
}

.filters-actions {
  display: flex;
  gap: 12px;
}

/* History Grid */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.history-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.history-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--glow-brand);
  border-color: var(--glass-border-hover);
}

.history-card-image {
  aspect-ratio: 1;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.history-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.placeholder-text {
  font-size: 12px;
}

.history-card-info {
  padding: 16px;
}

.history-card-model {
  display: inline-block;
  padding: 4px 10px;
  background: var(--gradient-brand);
  color: white;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
}

.history-card-user {
  display: inline-block;
  font-size: 11px;
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.history-card-date {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.history-card-prompt {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.history-card-status {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-completed {
  background: rgba(34, 197, 94, 0.2);
  color: var(--color-success);
}

.status-failed {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-danger);
}

.status-processing {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
}

.status-queued {
  background: rgba(180, 77, 255, 0.2);
  color: var(--color-purple);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 32px;
}

.pagination-info {
  color: var(--text-muted);
  font-size: 14px;
}

/* No Results */
.no-results {
  text-align: center;
  padding: 64px 32px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

.no-results p {
  margin-bottom: 16px;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 32px;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--glass-bg);
  color: var(--text-primary);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bg-card-hover);
}

.modal-image {
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.modal-image img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.modal-details {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.modal-model {
  padding: 6px 12px;
  background: var(--gradient-brand);
  color: white;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.modal-date {
  color: var(--text-muted);
  font-size: 13px;
}

.modal-status {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.modal-section h4 {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.modal-section p {
  margin: 0;
  line-height: 1.5;
  color: var(--text-secondary);
}

.modal-section pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-section summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-params {
  display: flex;
  gap: 8px;
}

.modal-user {
  font-size: 13px;
  color: var(--text-muted);
}

.modal-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 14px;
}

.modal-error p {
  color: var(--color-danger);
  margin: 0;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
}

/* ============================================
   Admin Pages
   ============================================ */
.admin-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.admin-header h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Admin Tables */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

.admin-table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table td.actions {
  display: flex;
  gap: 8px;
}

/* Models Grid */
.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.model-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s ease;
}

.model-card:hover {
  border-color: var(--glass-border-hover);
  box-shadow: var(--glow-brand);
}

.model-photos {
  height: 200px;
  background: var(--bg-tertiary);
}

.model-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.model-photo-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.model-info {
  padding: 20px;
}

.model-info h3 {
  margin-bottom: 4px;
}

.model-name {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.model-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.model-actions {
  display: flex;
  gap: 8px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.badge-default {
  background: var(--glass-bg);
  color: var(--text-muted);
}

.badge-primary {
  background: rgba(180, 77, 255, 0.2);
  color: var(--color-purple);
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--color-success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-danger);
}

/* Generation Model Badges */
.badge-gen-model {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-gen-banana {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.badge-gen-seedream {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.badge-gen-seedream3 {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.badge-gen-flash {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
}

.history-card-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* Admin Form */
.admin-form {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 32px;
  border-radius: var(--radius-lg);
  max-width: 800px;
}

.current-photo {
  margin-bottom: 16px;
}

.current-photo img {
  max-width: 150px;
  max-height: 150px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

/* Model Access Grid */
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.model-access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.model-access-item {
  cursor: pointer;
}

.model-access-item input {
  display: none;
}

.model-access-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  text-align: center;
}

.model-access-item input:checked + .model-access-card {
  border-color: var(--color-purple);
  background: rgba(180, 77, 255, 0.1);
}

.model-access-card:hover {
  border-color: var(--color-purple);
}

.model-access-card img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 8px;
}

.model-access-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.model-access-name {
  font-size: 13px;
  font-weight: 500;
}

.model-access-actions {
  display: flex;
  gap: 8px;
}

/* Gen Models Access (admin user form) */
.gen-models-access {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.gen-model-access-item {
  cursor: pointer;
}

.gen-model-access-item input {
  display: none;
}

.gen-model-access-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 24px;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  text-align: center;
}

.gen-model-access-item input:checked + .gen-model-access-card {
  border-color: var(--color-purple);
  background: rgba(180, 77, 255, 0.1);
}

.gen-model-access-card:hover {
  border-color: var(--color-purple);
}

.gen-model-access-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.gen-model-access-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.no-models-hint {
  color: var(--text-muted);
  font-size: 13px;
}

/* Inline Form */
.inline-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input {
  padding: 12px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}

.api-key-form-section {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.api-key-form-section h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

/* No Items */
.no-items {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.4s ease forwards;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--glass-bg) 25%, var(--bg-card-hover) 50%, var(--glass-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading {
  animation: pulse 2s infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-loading::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .generate-page {
    grid-template-columns: 1fr;
  }

  .generate-sidebar {
    display: none;
  }

  .main-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* -- Navbar: hamburger menu -- */
  .navbar {
    flex-wrap: wrap;
    padding: 8px 16px;
  }

  .nav-brand {
    flex: 1;
  }

  .navbar-logo {
    height: 40px;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: 2px;
    padding: 12px 0 4px;
    border-top: 1px solid var(--glass-border);
    margin-top: 8px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links .nav-link {
    padding: 12px 16px;
    width: 100%;
    text-align: left;
    border-radius: var(--radius-sm);
  }

  .nav-user {
    display: none;
    flex-basis: 100%;
    padding: 8px 0;
    border-top: 1px solid var(--glass-border);
  }

  .nav-user.open {
    display: flex;
  }

  /* -- Layout -- */
  .container,
  .generate-main,
  .history-page,
  .admin-page {
    padding: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .shot-type-selector {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .model-selector-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .model-selector-avatar,
  .model-selector-avatar-placeholder {
    width: 56px;
    height: 56px;
  }

  .filters-row {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }

  .history-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .modal-content {
    grid-template-columns: 1fr;
    max-height: 95vh;
    padding: 20px;
  }

  .modal-image {
    max-height: 40vh;
  }

  .modal-overlay {
    padding: 12px;
  }

  /* -- Touch targets -- */
  .btn-sm {
    padding: 10px 16px;
    min-height: 44px;
  }

  .ref-remove,
  .duet-ref-remove {
    display: flex;
  }

  .modal-close {
    width: 44px;
    height: 44px;
    font-size: 28px;
  }

  .lightbox-close {
    width: 44px;
    height: 44px;
    font-size: 28px;
  }

  /* -- iOS input zoom prevention -- */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px !important;
  }

  /* -- Admin tables responsive -- */
  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }

  .admin-table {
    min-width: 600px;
  }

  /* -- Login card mobile -- */
  .login-card {
    padding: 28px 20px;
    margin: 0 12px;
  }

  .login-logo img {
    height: 56px;
  }

  /* -- Result image responsive -- */
  .result-image-container img {
    max-height: 60vh;
  }

  /* -- Manual/Duet page padding -- */
  .manual-page,
  .duet-page {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .history-grid {
    grid-template-columns: 1fr;
  }

  .model-selector-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .ratio-selector {
    justify-content: center;
  }

  .shot-type-selector {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Manual Mode
   ============================================ */
.manual-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px;
}

.manual-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.manual-textarea {
  min-height: 100px;
  resize: none;
  overflow: hidden;
}

.manual-params {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.param-group {
  flex-shrink: 0;
}

.gen-model-selector.compact {
  gap: 8px;
}

.gen-model-card.compact {
  padding: 10px 18px;
}

.ratio-selector.compact {
  gap: 6px;
}

/* Ref Counter */
.ref-counter {
  float: right;
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--glass-bg);
}

.drop-zone:hover {
  border-color: var(--color-purple);
  background: rgba(180, 77, 255, 0.05);
}

.drop-zone-active {
  border-color: var(--color-red) !important;
  background: rgba(255, 61, 61, 0.08) !important;
  box-shadow: var(--glow-red);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.drop-zone-icon {
  font-size: 32px;
  color: var(--text-muted);
  line-height: 1;
}

.drop-zone-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.drop-zone-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Ref Gallery */
.ref-gallery {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  min-height: 0;
}

.ref-item {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--glass-border);
  cursor: grab;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.ref-item:hover {
  border-color: var(--color-purple);
}

.ref-dragging {
  opacity: 0.4;
}

.ref-drag-over {
  border-color: var(--color-red) !important;
  box-shadow: var(--glow-red);
}

.ref-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  background: var(--gradient-brand);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  z-index: 2;
  line-height: 1;
}

.ref-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.ref-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.ref-item:hover .ref-remove {
  display: flex;
}

.ref-actions {
  margin-top: 8px;
}

/* Session Feed */
.session-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.session-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  padding: 16px;
}

.session-card-image {
  width: 200px;
  min-height: 150px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  border-radius: var(--radius-md);
}

.session-card-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 24px;
}

.session-card-loading .spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--color-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.session-card-error {
  color: var(--color-danger);
  font-size: 13px;
  padding: 16px;
  text-align: center;
}

.session-card-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.session-card-refs {
  font-size: 12px;
  color: var(--text-muted);
}

.session-card-prompt {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.session-card-details {
  margin-top: 4px;
}

.session-card-details summary {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.session-card-details pre {
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
  margin-top: 8px;
}

.session-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  backdrop-filter: blur(20px);
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.lightbox-overlay img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: white;
  font-size: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ref-based ratio options */
.ratio-card-ref {
  position: relative;
  border-style: dashed !important;
}

.ratio-ref-badge {
  width: 20px;
  height: 20px;
  background: var(--gradient-brand);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.ratio-option-ref input:checked + .ratio-card-ref {
  border-style: solid !important;
}

/* Badge Manual */
.badge-gen-manual {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

/* Badge Duet */
.badge-gen-duet {
  background: rgba(236, 72, 153, 0.2);
  color: #ec4899;
}

/* Responsive Manual */
@media (max-width: 768px) {
  .manual-page {
    padding: 16px;
  }

  .manual-params {
    flex-direction: column;
    gap: 16px;
  }

  .ref-gallery {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }

  .session-card {
    grid-template-columns: 1fr;
  }

  .session-card-image {
    width: 100%;
    max-height: 300px;
  }

  .lightbox-overlay {
    padding: 8px;
  }
}

/* ============================================
   Duet Mode
   ============================================ */
.duet-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px;
}

.duet-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Person Grid — two columns */
.duet-persons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.duet-person-block {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.duet-person-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.duet-person-label {
  font-size: 16px;
  font-weight: 600;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Source toggle (DB / Manual) */
.duet-source-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.duet-source-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.duet-source-btn.active {
  background: var(--gradient-brand);
  color: white;
}

/* Prompt Optimizer Toggle */
.optimizer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.optimizer-toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.optimizer-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.optimizer-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  transition: all 0.3s ease;
}

.optimizer-toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.optimizer-toggle-switch input:checked + .optimizer-toggle-slider {
  background: var(--gradient-brand);
  border-color: transparent;
}

.optimizer-toggle-switch input:checked + .optimizer-toggle-slider::before {
  transform: translateX(18px);
  background: white;
}

.optimizer-toggle-label {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.optimizer-toggle-label strong {
  color: var(--text-primary);
  font-weight: 600;
}

.optimizer-toggle-hint {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* Model dropdown */
.duet-model-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
}

.duet-model-select:focus {
  outline: none;
  border-color: var(--color-purple);
}

/* Model ref preview thumbnails */
.duet-model-refs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.duet-model-ref-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--glass-border);
}

/* Mini drop zone */
.duet-drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--glass-bg);
  margin-bottom: 12px;
}

.duet-drop-zone:hover {
  border-color: var(--color-purple);
  background: rgba(180, 77, 255, 0.05);
}

.duet-drop-zone-active {
  border-color: var(--color-red) !important;
  background: rgba(255, 61, 61, 0.08) !important;
}

.duet-drop-zone-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* Mini ref gallery */
.duet-ref-gallery {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.duet-ref-item {
  position: relative;
  width: 70px;
  height: 70px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--glass-border);
}

.duet-ref-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.duet-ref-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 26px;
  height: 26px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.duet-ref-item:hover .duet-ref-remove {
  display: flex;
}

/* Person detail inputs */
.duet-detail-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
}

.duet-detail-input:focus {
  outline: none;
  border-color: var(--color-purple);
}

.duet-detail-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}

/* Interaction Zone */
.duet-section {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.duet-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Interaction preset chips */
.duet-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.duet-preset-chip {
  padding: 8px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.duet-preset-chip:hover {
  border-color: var(--color-purple);
  color: var(--text-primary);
}

.duet-preset-chip.active {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(180, 77, 255, 0.15));
  border-color: #ec4899;
  color: #ec4899;
}

/* Background radio toggle */
.duet-bg-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.duet-bg-option {
  cursor: pointer;
}

.duet-bg-option input {
  display: none;
}

.duet-bg-card {
  padding: 8px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.duet-bg-option input:checked + .duet-bg-card {
  border-color: var(--color-purple);
  color: var(--text-primary);
  background: rgba(180, 77, 255, 0.1);
}

/* Settings row */
.duet-settings-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.duet-setting-group {
  flex: 1;
  min-width: 120px;
}

.duet-setting-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.duet-setting-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}

.duet-setting-select:focus {
  outline: none;
  border-color: var(--color-purple);
}

/* Responsive Duet */
@media (max-width: 768px) {
  .duet-page {
    padding: 16px;
  }

  .duet-persons {
    grid-template-columns: 1fr;
  }

  .duet-settings-row {
    flex-direction: column;
  }
}

/* ============================================================
   Concurrent job grid (Normal + Manual) + new form controls
   ============================================================ */

.results-grid,
.session-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
  gap: 16px;
  margin-top: 24px;
  min-width: 0;
}

.job-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 0;
  transition: border-color 0.2s, transform 0.2s;
}
.job-card:hover { border-color: var(--glass-border-hover); }
.job-card-completed { border-color: rgba(34, 197, 94, 0.25); }
.job-card-failed { border-color: rgba(239, 68, 68, 0.3); }

.job-card-media {
  position: relative;
  width: 100%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  overflow: hidden;
}
.job-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.job-card-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 24px;
  min-height: 140px;
  text-align: center;
}
.job-card-status { font-size: 13px; }
.job-card-hint { min-height: 14px; display: block; }
.job-card-loading .spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--color-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.job-card-stalled { color: var(--color-warning); font-size: 12px; max-width: 180px; }
.job-card-error {
  color: var(--color-danger);
  font-size: 13px;
  padding: 18px;
  text-align: center;
}
.job-card-cancelled { color: var(--text-muted); font-size: 13px; padding: 24px; }

.job-cancel {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.job-cancel:hover { background: var(--color-danger); }

.job-card-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.job-card-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.job-card-refs { font-size: 11px; color: var(--text-muted); }
.job-card-promptline {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.job-card-prompt summary { font-size: 11px; color: var(--text-muted); cursor: pointer; }
.job-card-prompt pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  background: var(--bg-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
}
.job-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

.card-refine { display: flex; gap: 6px; margin-top: 6px; }
.card-refine input {
  flex: 1;
  min-width: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 12px;
}

.badge-res, .badge-batch {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: rgba(180, 77, 255, 0.18);
  color: var(--color-purple);
}
.badge-batch { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }

/* Segmented control (count / resolution) — matches .ratio-card / .gen-model-card glass aesthetic */
.segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.seg-option input { position: absolute; opacity: 0; pointer-events: none; }
.seg-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.seg-option:hover .seg-card {
  background: var(--bg-card-hover);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}
.seg-option input:checked + .seg-card {
  background: linear-gradient(135deg, rgba(255, 61, 61, 0.1) 0%, rgba(180, 77, 255, 0.1) 100%);
  border-color: var(--color-purple);
  box-shadow: var(--glow-purple);
  color: var(--text-primary);
}
/* Locked options (e.g. non-2K quality when Nano Banana 2 / flash is selected) */
.seg-disabled .seg-card {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.form-group-split { display: flex; gap: 20px; flex-wrap: wrap; }
.param-half { flex: 1; min-width: 160px; }
.field-hint { display: block; font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.form-status { font-size: 13px; color: var(--text-secondary); margin-top: 10px; min-height: 18px; }

/* Task 1: Video/Seedance badges */
.badge-gen-video { background: rgba(168, 85, 247, 0.18); color: #c084fc; border: 1px solid rgba(168,85,247,0.4); }
.badge-gen-seedance { background: rgba(99, 102, 241, 0.18); color: #818cf8; border: 1px solid rgba(99,102,241,0.4); }

/* Task 4: look gallery, @-chips, preview, help drawer */
.look-gallery { display:flex; gap:10px; flex-wrap:wrap; margin-top:10px; }
.look-card { position:relative; width:90px; cursor:pointer; border:2px solid transparent; border-radius:10px; overflow:hidden; background:rgba(255,255,255,0.04); }
.look-card.active { border-color:#b44dff; box-shadow:0 0 12px rgba(180,77,255,0.5); }
.look-card img { width:90px; height:90px; object-fit:cover; display:block; }
.look-card .look-name { display:block; font-size:11px; padding:3px 4px; }
.video-ref-chips { display:flex; flex-direction:column; gap:6px; margin-top:8px; }
.video-ref-chip { display:flex; align-items:center; gap:6px; background:rgba(255,255,255,0.05); border-radius:8px; padding:4px 8px; }
.video-ref-chip .ref-tag { cursor:pointer; color:#818cf8; font-weight:600; }
.video-ref-chip .ref-desc { flex:1; background:transparent; border:1px solid rgba(255,255,255,0.12); border-radius:6px; color:#eee; padding:3px 6px; }
.video-ref-chip .ref-del { background:none; border:none; color:#ff6b6b; cursor:pointer; font-size:16px; }
.at-picker { display:flex; flex-direction:column; gap:2px; background:#1a1a24; border:1px solid rgba(180,77,255,0.4); border-radius:8px; padding:4px; margin-top:4px; }
.at-picker .at-opt { text-align:left; background:none; border:none; color:#ddd; padding:4px 8px; cursor:pointer; border-radius:4px; }
.at-picker .at-opt:hover { background:rgba(180,77,255,0.2); }
.video-preview-meta { display:flex; align-items:center; gap:12px; margin:8px 0; }
.cost-badge { background:rgba(255,61,61,0.15); color:#ff8a8a; border-radius:8px; padding:2px 10px; font-weight:600; }
.video-warnings div { color:#ffcc66; font-size:13px; }
.video-asset-warning { color:#ffcc66; font-size:13px; margin-top:6px; }
.video-help-drawer { position:fixed; right:0; top:0; height:100%; width:340px; background:#12121a; border-left:1px solid rgba(180,77,255,0.3); padding:24px; overflow:auto; z-index:50; }

/* Seedance video page — new UX elements (mode hint, look empty/placeholder) + responsive */
.mode-hint { font-size:13px; color:#9aa0b5; margin-top:8px; line-height:1.5; }
.look-empty { font-size:13px; color:#9aa0b5; padding:10px 12px; border:1px dashed rgba(255,255,255,0.14); border-radius:8px; }
.look-thumb-placeholder { display:flex; align-items:center; justify-content:center; width:100%; aspect-ratio:1/1; background:linear-gradient(135deg,#2a2a36,#1a1a24); color:#b44dff; font-weight:700; font-size:28px; border-radius:8px; }
.video-help-drawer .video-help-close, #video-help-close { cursor:pointer; }
.video-ref-chip { flex-wrap:nowrap; }
.ref-thumb { width:36px; height:36px; flex:none; object-fit:cover; border-radius:6px; background:rgba(255,255,255,0.06); }
.ref-thumb-icon { display:flex; align-items:center; justify-content:center; font-size:18px; }

@media (max-width: 768px) {
  .video-help-drawer { width:100%; max-width:100%; padding:18px; }
  #video-mode-presets { flex-wrap:wrap; }
  /* override the earlier mobile rule's flex-direction:column so 45% basis wraps 2-up */
  .duet-settings-row { flex-direction:row; flex-wrap:wrap; gap:10px; }
  .duet-settings-row .duet-setting-group { flex:1 1 45%; min-width:120px; }
  .look-gallery { gap:8px; }
}

.cap-row{display:grid;grid-template-columns:minmax(150px,1.3fr) 130px 1.5fr;gap:10px;margin-bottom:6px;align-items:center}
.cap-row .cap-label{font-weight:500;color:#e8e8f0}
@media(max-width:640px){.cap-row{grid-template-columns:1fr;gap:6px;padding:10px;border:1px solid rgba(255,255,255,.08);border-radius:8px}}

/* ============================================
   Cards / Models Info table
   ============================================ */
.table-scroll{overflow-x:auto;border-radius:12px}
.info-table{width:100%;border-collapse:collapse;font-size:.92rem}
.info-table th,.info-table td{padding:10px 12px;border-bottom:1px solid rgba(255,255,255,.07);text-align:center;white-space:nowrap}
.info-table th{position:sticky;top:0;background:#15151f;color:#cbb6ff;font-weight:600}
.info-table td{vertical-align:top}
.info-table .model-cell{text-align:left}
.info-table .model-cell .model-cell-inner{display:flex;align-items:center;gap:10px}
.info-table .avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;cursor:zoom-in;border:1px solid rgba(255,255,255,.15)}
.info-table .nick{font-weight:600}
.info-table td.cap.yes{color:#4ade80}.info-table td.cap.no{color:#f87171}.info-table td.cap.limited{color:#fbbf24}
.info-table td.cap{white-space:normal;vertical-align:top}
.cap-mark{font-size:1.05rem;line-height:1}
.cap-note{display:block;margin:4px auto 0;max-width:180px;font-size:.72rem;line-height:1.25;color:#9a9ab0;white-space:normal;font-weight:400}
/* Models Info: full-width matrix that fits one screen — wrapping centered headers, and
   columns auto-size to content so skills WITHOUT a comment collapse to a narrow icon column
   while commented ones stay wide enough to read. Scoped to .cards-page so other tables (admin,
   history, translator) keep their layout. */
.cards-page .info-table{font-size:.86rem;table-layout:auto}
.cards-page .info-table th{white-space:normal;overflow-wrap:break-word;text-align:center;
  vertical-align:bottom;max-width:96px;line-height:1.18;padding:8px 6px}
.cards-page .info-table td{padding:8px 7px}
.cards-page .info-table td.cap{min-width:32px}
.cards-page .info-table .model-cell{min-width:138px}
.cards-page .cap-note{max-width:140px}
/* Seedance prep: drag-and-drop feedback on the editor stage */
.drag-over{outline:2px dashed #ff3d3d;outline-offset:-6px;background:rgba(255,61,61,.06)}
/* Card-management control: a labelled toggle whose panel FLOATS (absolute) so opening it
   never reflows the wide table / resets the horizontal scroll. No default disclosure ▶ marker. */
.card-admin{position:relative;display:inline-block;margin-left:6px;text-align:left}
.card-admin>summary{list-style:none;cursor:pointer;display:inline-flex;align-items:center;gap:5px;
  padding:6px 10px;border-radius:8px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.14);
  font-size:.8rem;color:#cbb6ff;white-space:nowrap}
.card-admin>summary::-webkit-details-marker{display:none}
.card-admin>summary::marker{content:""}
.card-admin[open]>summary{background:rgba(180,77,255,.20);color:#fff}
.card-admin-panel{position:absolute;right:0;top:calc(100% + 6px);z-index:60;min-width:220px;
  display:flex;flex-direction:column;gap:8px;padding:12px;border-radius:12px;
  background:#16161f;border:1px solid rgba(255,255,255,.16);box-shadow:0 18px 44px -16px rgba(0,0,0,.75)}
.card-admin-panel input[type=file]{font-size:.78rem;color:#cbb6ff;max-width:100%}
.overlay{position:fixed;inset:0;z-index:1000;background:rgba(5,5,12,.92);display:flex;flex-direction:column}
.overlay[hidden]{display:none}
.overlay-bar{display:flex;justify-content:space-between;align-items:center;padding:12px 18px;color:#fff}
#card-frame{flex:1;width:100%;border:0;background:#fff}
#lightbox{align-items:center;justify-content:center;cursor:zoom-out}
#lightbox-img{max-width:92vw;max-height:92vh;border-radius:12px}

/* === Knowledge Base (KB) === */
.kb-page{max-width:1100px}
/* Branded page heading for direct-child h1 (KB «База знаний», cards «Models Info»).
   doc/translator h1 are grandchildren of .page (inside .overlay-bar) — unaffected. */
.page>h1{font-size:1.7rem;font-weight:700;margin:0 0 14px;
  background:var(--gradient-brand);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
.block-title{font-size:1.15rem;font-weight:700;margin:26px 0 2px;color:#cbb6ff;letter-spacing:.01em}
.kb-lede{color:var(--muted,#9a9ab0);font-size:1rem;line-height:1.55;max-width:62ch;margin:0 0 8px}
.kb-section-sub{color:var(--muted,#9a9ab0);font-size:.85rem;margin:0 0 12px}
.kb-links{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(280px,100%),1fr));gap:16px;margin:12px 0 30px}
.kb-docs{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(216px,100%),1fr));gap:14px;margin:12px 0 30px}
.kb-card{display:flex;align-items:center;gap:14px;padding:16px 18px;min-height:64px;border-radius:14px;
  background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.08);text-decoration:none;color:inherit;
  transition:border-color .15s,transform .15s,box-shadow .15s}
.kb-card:hover{border-color:#b44dff;transform:translateY(-2px);box-shadow:0 12px 32px -14px rgba(180,77,255,.5)}
.kb-card:focus-visible{outline:2px solid #b44dff;outline-offset:2px}
.kb-card .kb-ic{font-size:1.7rem;flex:none;line-height:1}.kb-card .kb-title{font-weight:600}.kb-card .kb-ext{margin-left:auto;opacity:.6}
.kb-card-lg{flex-direction:column;align-items:flex-start;padding:22px 24px;gap:8px;min-height:118px;
  background:linear-gradient(135deg,rgba(255,61,93,.12),rgba(180,77,255,.12));border-color:rgba(180,77,255,.30)}
.kb-card-lg .kb-ic{font-size:2.1rem}.kb-card-lg .kb-title{font-size:1.18rem;font-weight:700}
.kb-card-lg .kb-sub{color:var(--muted,#9a9ab0);font-size:.86rem;line-height:1.45}
/* Doc viewer: fill the viewport (single iframe scrollbar, no outer page scroll).
   76px ≈ container vertical padding (64px) + sticky-navbar slack vs --navbar-height. */
.doc-page{display:flex;flex-direction:column;height:calc(100dvh - var(--navbar-height) - 76px);min-height:360px}
.doc-page .overlay-bar{flex:none;gap:12px;flex-wrap:wrap}
.doc-page .overlay-bar h1{font-size:clamp(1.2rem,1.1rem + .6vw,1.5rem);font-weight:700;line-height:1.2;
  background:var(--gradient-brand);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
.doc-frame{flex:1;width:100%;height:auto;min-height:0;border:0;border-radius:12px;background:#fff}
.role-badge{display:inline-block;padding:6px 14px;border-radius:8px;font-weight:600;font-size:.95rem;
  background:rgba(180,77,255,.15);border:1px solid rgba(180,77,255,.35);color:#cbb6ff}
.role-badge-admin{background:rgba(255,61,93,.15);border-color:rgba(255,61,93,.35);color:#ff9bb0}

/* === Translator (AntiDeepL) === */
.tr-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}
@media(max-width:880px){.tr-grid{grid-template-columns:1fr}}
.translator-page textarea,.translator-page input[type=text]{width:100%;margin:6px 0 12px;padding:10px;border-radius:10px;
  background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.1);color:inherit;font-size:1rem}
.tr-row{display:flex;gap:10px;align-items:center;justify-content:space-between}
.tr-english{white-space:pre-wrap;background:rgba(180,77,255,.08);border:1px solid rgba(180,77,255,.25);
  border-radius:10px;padding:12px;font-size:1.05rem;line-height:1.5}
.tr-badges{display:flex;gap:8px;margin-bottom:8px}
.tr-badges .badge{background:rgba(255,255,255,.08);border-radius:999px;padding:4px 10px;font-size:.8rem}
.tr-delta{opacity:.8;font-size:.9rem}
.tr-warn{color:#fbbf24;margin:8px 0}
.tr-presets{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.overlay-body{overflow:auto;padding:18px 24px;color:#e2e2ee}
.overlay-body table{max-width:900px}
.glass{background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.08);border-radius:14px;padding:16px}

.nav-sep{display:inline-block;width:1px;height:20px;background:rgba(255,255,255,.18);margin:0 6px;vertical-align:middle}

/* === Locked 'user' screen === */
.locked-screen{display:flex;align-items:center;justify-content:center;min-height:calc(100vh - var(--navbar-height) - 64px);padding:24px}
.locked-card{max-width:480px;text-align:center;padding:44px 36px;border-radius:18px;
  background:linear-gradient(135deg,rgba(255,61,93,.10),rgba(180,77,255,.10));
  border:1px solid rgba(180,77,255,.30)}
.locked-card .locked-icon{font-size:3rem;line-height:1;margin-bottom:14px}
.locked-card h1{font-size:1.5rem;font-weight:800;margin:0 0 12px}
.locked-card p{color:var(--muted,#9a9ab0);line-height:1.6;margin:0 0 22px}

/* === Translator stats dashboard === */
.stat-filters{display:flex;flex-wrap:wrap;gap:14px;align-items:flex-end;margin:6px 0 22px}
.stat-filters label{display:flex;flex-direction:column;gap:4px;font-size:.82rem;color:var(--muted,#9a9ab0)}
.stat-filters input,.stat-filters select{padding:8px 10px;border-radius:8px;background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.12);color:#ececf3;font:inherit}
.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:14px;margin:0 0 28px}
.stat-card{padding:18px 20px;border-radius:14px;background:linear-gradient(135deg,rgba(255,61,93,.10),rgba(180,77,255,.10));
  border:1px solid rgba(180,77,255,.28);display:flex;flex-direction:column;gap:6px}
.stat-card .stat-num{font-size:1.7rem;font-weight:800;line-height:1.1}
.stat-card .stat-lbl{font-size:.8rem;color:var(--muted,#9a9ab0);letter-spacing:.02em}

/* === Mobile responsiveness fixes (audit 2026-06-20) === */
@media (max-width: 768px) {
  /* Generator/mode/operator-access card rows (user form): wrap 2-up instead of overflowing. */
  .gen-models-access { flex-wrap: wrap; }
  .gen-model-access-item { flex: 1 1 calc(50% - 6px); }
  .gen-model-access-card { padding: 12px 10px; }
  /* History detail modal actions: wrap to avoid 3 admin buttons overflowing; full tap targets. */
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; min-width: 120px; min-height: 44px; }
  .btn-primary { padding: 14px 20px; }
}
@media (max-width: 480px) {
  /* Translator explainer comparison table: let cells wrap on phones (already in .table-scroll). */
  #antideepl .info-table td, #antideepl .info-table th { white-space: normal; }
}
