/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --primary-bg: #eef2ff;
  --primary-glow: rgba(79,70,229,0.15);
  --accent: #06b6d4;
  --accent-light: #67e8f9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.25);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Modern Navigation === */
.top-nav {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(226,232,240,0.8);
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 64px;
}

.top-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.3px;
}

.nav-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-links a {
  color: var(--gray-500);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--primary);
  background: var(--primary-bg);
}

.nav-links a.active {
  color: var(--primary);
  background: var(--primary-bg);
}

/* Hamburger button (mobile) */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--gray-600);
  border-radius: 2px;
  transition: all 0.3s;
}

.nav-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile drawer overlay */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s;
}

.drawer-overlay.show {
  display: block;
  opacity: 1;
}

/* Mobile drawer */
.drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100%;
  background: white;
  z-index: 999;
  padding: 20px;
  padding-top: 80px;
  box-shadow: var(--shadow-xl);
  transition: left 0.3s ease;
  overflow-y: auto;
}

.drawer.open { left: 0; }

.drawer a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--gray-700);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
}

.drawer a:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.drawer .drawer-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 12px 16px 6px;
  letter-spacing: 0.05em;
}

/* === Main Content === */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  min-height: calc(100vh - 64px);
}

/* === Hero Section (Home) === */
.hero {
  text-align: center;
  padding: 48px 20px 40px;
  position: relative;
}

.hero::after {
  content: '';
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.hero h1 {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 50%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero p {
  font-size: 17px;
  color: var(--gray-500);
  max-width: 560px;
  margin: 0 auto 32px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  display: block;
  line-height: 1.2;
}

.hero-stat-label {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 2px;
}

/* === Section Title === */
.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.section-subtitle {
  font-size: 14px;
  color: var(--gray-400);
  margin-bottom: 24px;
}

/* === Tool Grid === */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 20px;
}

.tool-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--gray-100);
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.tool-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.tool-card:hover::before {
  transform: scaleX(1);
}

.tool-card .tool-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 18px;
  position: relative;
}

.tool-card .tool-icon::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tool-card:hover .tool-icon::after {
  opacity: 1;
}

/* Icon color variants */
.icon-blue { background: linear-gradient(135deg, #dbeafe, #eff6ff); }
.icon-green { background: linear-gradient(135deg, #d1fae5, #ecfdf5); }
.icon-purple { background: linear-gradient(135deg, #ede9fe, #f5f3ff); }
.icon-orange { background: linear-gradient(135deg, #fed7aa, #fff7ed); }
.icon-red { background: linear-gradient(135deg, #fce4ec, #fff1f2); }
.icon-cyan { background: linear-gradient(135deg, #cffafe, #ecfeff); }
.icon-indigo { background: linear-gradient(135deg, #e0e7ff, #eef2ff); }
.icon-pink { background: linear-gradient(135deg, #fce7f3, #fff1f2); }

.tool-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-900);
}

.tool-card p {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.6;
}

.tool-card .tool-arrow {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.3s;
  opacity: 0;
}

.tool-card:hover .tool-arrow {
  opacity: 1;
  background: var(--primary-bg);
  color: var(--primary);
}

/* === Tool Page Layout === */
.tool-page {
  max-width: 720px;
  margin: 0 auto;
}

.tool-header {
  text-align: center;
  margin-bottom: 32px;
  padding: 20px 0;
}

.tool-header .tool-header-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.tool-header h2 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.tool-header p {
  color: var(--gray-500);
  font-size: 15px;
}

/* === Form Card === */
.form-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  padding: 32px;
  margin-bottom: 24px;
  transition: box-shadow 0.2s;
}

.form-card:hover {
  box-shadow: var(--shadow);
}

.form-card .card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-card .card-title .card-icon {
  font-size: 18px;
}

/* === Upload Zone === */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--gray-50);
  position: relative;
}

.upload-zone:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.upload-zone .upload-icon {
  font-size: 44px;
  margin-bottom: 12px;
  display: block;
}

.upload-zone .upload-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.upload-zone .upload-hint {
  font-size: 13px;
  color: var(--gray-400);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* === File List === */
.file-list {
  margin-top: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--gray-100);
  animation: slideIn 0.3s ease;
}

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

.file-item .file-icon { font-size: 20px; }
.file-item .file-info { flex: 1; }
.file-item .file-info .name { font-size: 14px; font-weight: 500; color: var(--gray-700); }
.file-item .file-info .size { font-size: 12px; color: var(--gray-400); }
.file-item .file-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.2s;
  line-height: 1;
}
.file-item .file-remove:hover { background: #fef2f2; transform: scale(1.1); }

/* === Form Elements === */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group .hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
  line-height: 1.6;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-800);
  background: white;
  transition: all 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

/* === Radio / Toggle Group === */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-group label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.2s;
  margin-bottom: 0;
  background: white;
}

.radio-group label:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.radio-group input[type="radio"],
.radio-group input[type="checkbox"] {
  accent-color: var(--primary);
}

.radio-group label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-bg);
  font-weight: 500;
  box-shadow: 0 0 0 1px var(--primary);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79,70,229,0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  box-shadow: 0 4px 14px rgba(16,185,129,0.2);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16,185,129,0.3);
}

.btn-outline {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-800);
}

.btn-lg {
  padding: 14px 36px;
  font-size: 16px;
  border-radius: var(--radius);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* === Result Page === */
.result-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  padding: 48px 40px;
  text-align: center;
}

.result-card .result-icon {
  font-size: 64px;
  margin-bottom: 16px;
  display: block;
  animation: popIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.result-card h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.result-card .result-message {
  font-size: 16px;
  color: var(--gray-500);
  margin-bottom: 28px;
}

.result-card .file-info-box {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 24px;
  margin: 0 auto 28px;
  max-width: 400px;
  display: flex;
  justify-content: space-around;
  gap: 24px;
  border: 1px solid var(--gray-100);
}

.result-card .file-info-box .info-item {
  text-align: center;
}

.result-card .file-info-box .info-item .val {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
}

.result-card .file-info-box .info-item .lbl {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}

.result-card .btn-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* === Loading Spinner === */
.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-text { display: none; }

/* === Alert === */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* === Progress bar === */
.progress-bar {
  display: none;
  width: 100%;
  height: 4px;
  background: var(--gray-100);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 16px;
}

.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* === Compression level cards === */
.compression-levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.compression-levels label {
  position: relative;
  display: block;
  padding: 16px 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  background: white;
}

.compression-levels label:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.compression-levels label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-bg);
  box-shadow: 0 0 0 1px var(--primary);
}

.compression-levels label .level-name {
  font-size: 15px;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.compression-levels label .level-desc {
  font-size: 11px;
  color: var(--gray-400);
}

.compression-levels input[type="radio"] {
  position: absolute;
  opacity: 0;
}

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 40px 24px;
  color: var(--gray-400);
  font-size: 13px;
  border-top: 1px solid var(--gray-100);
  max-width: 1200px;
  margin: 0 auto;
}

.site-footer p {
  line-height: 1.8;
}

.site-footer .footer-link {
  color: var(--gray-500);
  text-decoration: none;
}

.site-footer .footer-link:hover {
  color: var(--primary);
}

/* === Responsive === */
@media (max-width: 1024px) {
  .tool-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 768px) {
  .top-nav-inner {
    padding: 0 16px;
  }

  .nav-links {
    display: none;
  }

  .nav-toggle {
    display: flex;
  }

  .main {
    padding: 20px 16px 60px;
  }

  .hero {
    padding: 32px 12px 28px;
  }

  .hero h1 {
    font-size: 30px;
  }

  .hero p {
    font-size: 15px;
  }

  .hero-stats {
    gap: 24px;
  }

  .hero-stat-value {
    font-size: 24px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .tool-card {
    padding: 20px 18px;
  }

  .tool-card .tool-arrow {
    opacity: 1;
    background: var(--primary-bg);
    color: var(--primary);
  }

  .tool-header h2 {
    font-size: 24px;
  }

  .form-card {
    padding: 20px;
  }

  .result-card {
    padding: 28px 20px;
  }

  .result-card .file-info-box {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }

  .radio-group {
    flex-direction: column;
  }

  .upload-zone {
    padding: 28px 16px;
  }

  .compression-levels {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 26px;
  }

  .tool-header .tool-header-icon {
    font-size: 36px;
  }

  .compression-levels {
    grid-template-columns: 1fr 1fr;
  }

  .result-card .btn-group {
    flex-direction: column;
  }

  .result-card .btn-group .btn {
    width: 100%;
  }
}

/* === Utility === */
.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.fade-in {
  animation: fadeIn 0.5s ease;
}

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