:root {
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --transition: 0.15s ease;
}

/* Light Mode Theme */
:root[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-input-active: #ffffff;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --primary: #059669;
  --primary-hover: #047857;
  --primary-subtle: #ecfdf5;
  --primary-border: #a7f3d0;
  --primary-focus-ring: rgba(5, 150, 105, 0.2);
  
  --danger: #dc2626;
  --danger-subtle: #fef2f2;
  --warning: #d97706;
  --warning-subtle: #fffbeb;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 45px -10px rgba(0, 0, 0, 0.18);
  
  --progress-track: #e2e8f0;
  --qr-bg: #ffffff;
  --qr-border: #e2e8f0;
}

/* Dark Mode Theme (Default) */
:root, :root[data-theme="dark"] {
  --bg-page: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #21262d;
  --bg-input: #0d1117;
  --bg-input-active: #161b22;
  --border-subtle: #30363d;
  --border-strong: #484f58;
  
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-subtle: rgba(16, 185, 129, 0.12);
  --primary-border: rgba(16, 185, 129, 0.35);
  --primary-focus-ring: rgba(16, 185, 129, 0.25);
  
  --danger: #f85149;
  --danger-subtle: rgba(248, 81, 73, 0.12);
  --warning: #d29922;
  --warning-subtle: rgba(210, 153, 34, 0.12);
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 25px 50px rgba(0, 0, 0, 0.65);
  
  --progress-track: #21262d;
  --qr-bg: #ffffff;
  --qr-border: #30363d;
}

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

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition), color var(--transition);
}

.container {
  width: 100%;
  max-width: 660px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  gap: 12px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.logo-icon img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: contain;
  display: block;
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.logo-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.theme-toggle-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.app-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  transition: all var(--transition);
}

.app-header-badge:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary-hover);
}

/* Promo Banner Component */
.promo-banner {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  overflow: hidden;
  transition: border-color var(--transition);
}

.promo-banner:hover {
  border-color: var(--border-strong);
}

.promo-tag {
  position: absolute;
  top: 6px;
  left: 12px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

.promo-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding-top: 6px;
}

.promo-banner-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  display: block;
}

.promo-banner-text {
  flex: 1;
  min-width: 0;
}

.promo-banner-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.promo-banner-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.promo-badge {
  font-size: 0.68rem;
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

.promo-banner-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.promo-banner-cta {
  flex-shrink: 0;
}

.promo-banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}

.promo-banner-btn:hover {
  background: var(--border-subtle);
  color: var(--text-main);
}

.promo-banner-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.15rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
}

.promo-banner-close:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

/* Tabs */
.tab-nav {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.tab-btn.active {
  background: var(--bg-input-active);
  color: var(--text-main);
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-md);
  transition: background-color var(--transition), border-color var(--transition);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-main);
}

.card-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: -10px;
}

.badge-tag {
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.03em;
  border: 1px solid var(--primary-border);
}

/* Code Input */
.code-input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.code-input-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.code-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-align: center;
  padding: 12px 16px;
  outline: none;
  font-family: var(--font-mono);
  transition: all var(--transition);
}

.code-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus-ring);
  background: var(--bg-input-active);
}

.code-input::placeholder {
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

/* Info Box / Status Card */
.info-card {
  background: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.info-card.warning {
  background: var(--warning-subtle);
  border-color: rgba(217, 119, 6, 0.3);
}

.info-card.error {
  background: var(--danger-subtle);
  border-color: rgba(220, 38, 38, 0.3);
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition), border-color var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}

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

/* File Drop Zone */
.dropzone {
  border: 1.5px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-input);
  text-align: center;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.25rem;
}

.dropzone-text {
  font-size: 0.9rem;
  font-weight: 500;
}

.dropzone-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* File Selected Card */
.file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.file-icon {
  font-size: 1.35rem;
}

.file-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Radio Cards (Mode Selector) */
.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.mode-option:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.mode-option.selected {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.mode-radio {
  margin-top: 3px;
  accent-color: var(--primary);
}

.mode-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.mode-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}

.mode-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Code & QR Section */
.code-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
}

.big-code-display {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--primary);
  background: var(--bg-card);
  padding: 8px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.code-actions {
  display: flex;
  gap: 8px;
}

#qrcode-container {
  background: var(--qr-bg);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--qr-border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

/* Progress Section — Clean, Solid, No AI Gradients */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
}

.progress-label {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.progress-percent {
  font-family: var(--font-mono);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.88rem;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--progress-track);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Security Ribbon */
.security-ribbon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
}

.security-ribbon svg {
  color: var(--primary);
}

/* About / Security Card Details */
.feature-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.feature-icon {
  font-size: 1.15rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.feature-text h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.feature-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.feature-text a {
  color: var(--primary);
  text-decoration: underline;
}

/* Toast Notifications */
#toast {
  position: fixed;
  bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 9999;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Android Interstitial / Fullscreen Promo Modal */
.android-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10000;
  animation: modalFadeIn 0.2s ease forwards;
}

.android-modal-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.android-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}

.android-modal-close:hover {
  color: var(--text-main);
}

.android-modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 14px;
}

.android-modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.android-modal-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.android-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.android-modal-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 16px;
}

.android-modal-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 18px;
  text-align: left;
}

.android-modal-feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-main);
}

.android-modal-feature-item .feature-bullet {
  font-size: 0.95rem;
}

.android-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.android-btn-download {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 0.92rem;
  padding: 11px 18px;
}

.android-btn-dismiss {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 6px;
  transition: color var(--transition);
}

.android-btn-dismiss:hover {
  color: var(--text-muted);
  text-decoration: underline;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { transform: translateY(20px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 540px) {
  .app-header {
    flex-wrap: wrap;
  }
  .card {
    padding: 18px;
  }
  .code-input {
    font-size: 1.4rem;
    letter-spacing: 0.15em;
  }
  .promo-banner-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .promo-banner-cta {
    width: 100%;
  }
  .promo-banner-btn {
    width: 100%;
    justify-content: center;
  }
}
