:root {
  --bg: #0b0f17;
  --surface: #141c28;
  --surface-hover: #1c2738;
  --border: #253347;
  --border-focus: #f38020;
  --text-main: #f0f6fc;
  --text-muted: #8b9bb4;
  --cf-orange: #f38020;
  --primary: #a8322a;
  --accent: #d9aa69;
  --success: #238636;
  --warning: #d29922;
  --radius: 12px;
  --transition: all 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1350px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  font-size: 32px;
  background: linear-gradient(135deg, #f38020, #faad3f);
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(243, 128, 32, 0.35);
}

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
}

.header-badges {
  display: flex;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.badge-cf {
  background: rgba(243, 128, 32, 0.15);
  color: #f38020;
  border-color: rgba(243, 128, 32, 0.3);
}
.cf-dot { background: #f38020; }

.badge-success {
  background: rgba(35, 134, 54, 0.15);
  color: #3fb950;
  border-color: rgba(63, 185, 80, 0.3);
}
.badge-success .dot { background: #3fb950; }

.badge-warning {
  background: rgba(210, 153, 34, 0.15);
  color: #d29922;
  border-color: rgba(210, 153, 34, 0.3);
}

.badge-neutral {
  background: rgba(139, 148, 158, 0.15);
  color: var(--text-muted);
  border-color: var(--border);
}

/* Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 992px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.grid-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(37, 51, 71, 0.8);
}

.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sample-badge {
  background: rgba(243, 128, 32, 0.15);
  color: #f38020;
  border: 1px solid rgba(243, 128, 32, 0.4);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-sample-badge:hover {
  background: rgba(243, 128, 32, 0.25);
  border-color: #f38020;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text-main);
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  background: rgba(11, 15, 23, 0.5);
  cursor: pointer;
  transition: var(--transition);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--cf-orange);
  background: rgba(243, 128, 32, 0.06);
}

.drop-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.drop-title {
  font-size: 14px;
  color: var(--text-main);
}

.drop-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.btn-link {
  background: none;
  border: none;
  color: #58a6ff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-size: inherit;
}

/* Live Preview */
.preview-card {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.preview-wrapper {
  flex: 1;
  min-height: 480px;
  background: #06090e;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.preview-placeholder {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: transparent;
}

/* Form inputs & controls */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-text-action {
  background: none;
  border: none;
  color: var(--cf-orange);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  transition: var(--transition);
}

.btn-text-action:hover {
  text-decoration: underline;
}

.form-row {
  display: flex;
  gap: 16px;
}

.col-half {
  flex: 1;
}

.form-input, .form-select {
  width: 100%;
  background: #0b0f17;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--cf-orange);
  box-shadow: 0 0 0 3px rgba(243, 128, 32, 0.2);
}

/* Ratio Presets */
.ratio-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.preset-btn {
  background: #0b0f17;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preset-btn:hover {
  background: var(--surface-hover);
  border-color: var(--cf-orange);
}

.preset-btn.active {
  border-color: var(--cf-orange);
  background: rgba(243, 128, 32, 0.12);
  box-shadow: 0 0 12px rgba(243, 128, 32, 0.25);
}

.preset-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.preset-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.preset-res {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--cf-orange);
  margin-top: 2px;
}

.preset-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Primary Action Button */
.btn-primary-action {
  width: 100%;
  background: linear-gradient(135deg, #f38020, #e0483c);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: var(--transition);
  box-shadow: 0 8px 24px rgba(243, 128, 32, 0.35);
  letter-spacing: 0.5px;
  margin-top: 8px;
}

.btn-primary-action:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(243, 128, 32, 0.55);
}

.btn-primary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Progress View */
.progress-view {
  padding: 16px 0;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-msg {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.progress-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 800;
  color: var(--cf-orange);
}

.progress-bar-container {
  height: 12px;
  background: #0b0f17;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f38020, #e0483c);
  border-radius: 6px;
  transition: width 0.2s ease;
  box-shadow: 0 0 12px rgba(243, 128, 32, 0.5);
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  background: #0b0f17;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.stat-label {
  color: var(--text-muted);
}

.stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text-main);
}

/* Success View */
.success-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(35, 134, 54, 0.15);
  border: 1px solid rgba(63, 185, 80, 0.3);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 18px;
}

.success-icon {
  font-size: 28px;
}

.success-banner h3 {
  font-size: 16px;
  font-weight: 700;
  color: #3fb950;
}

.result-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.player-wrapper {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: center;
}

.output-player {
  max-width: 100%;
  max-height: 480px;
  display: block;
}

.result-actions {
  display: flex;
  gap: 12px;
}

.btn-action {
  flex: 1;
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  text-align: center;
}

.btn-download {
  background: var(--success);
  color: #fff;
  border: none;
}

.btn-download:hover {
  background: #2ea043;
}


/* ==================== CỔNG NHẬN DIỆN CON NGƯỜI (HUMAN VERIFICATION GATE) ==================== */
.human-gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 19, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.human-gate-card {
  background: #0f172a;
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 30px rgba(99, 102, 241, 0.15);
  border-radius: 20px;
  max-width: 460px;
  width: 100%;
  padding: 32px 28px;
  text-align: center;
  position: relative;
  animation: cardFadeIn 0.3s ease-out;
}

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

.human-gate-badge {
  display: inline-block;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.human-gate-title {
  font-size: 20px;
  font-weight: 800;
  color: #f8fafc;
  margin: 0 0 10px;
}

.human-gate-desc {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.6;
  margin: 0 0 24px;
}

.turnstile-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  user-select: none;
}

.turnstile-label {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  flex: 1;
}

.turnstile-checkbox {
  display: none;
}

.custom-checkbox {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid #64748b;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.turnstile-label:hover .custom-checkbox {
  border-color: #818cf8;
}

.custom-checkbox.verifying {
  border-color: #818cf8;
  background: rgba(99, 102, 241, 0.1);
}

.custom-checkbox.verified {
  border-color: #10b981;
  background: #10b981;
}

.custom-checkbox .check-icon {
  color: #fff;
  font-weight: 900;
  font-size: 16px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.turnstile-text {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  text-align: left;
}

.turnstile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 14px;
  border-left: 1px solid #334155;
}

.gate-alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
  text-align: left;
}

.human-gate-footer {
  font-size: 12px;
  color: #64748b;
}
