/* === CSS Variables (Dark Theme - matching menge.vip) === */
:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-card-hover: #1a1a1a;
  --bg-input: #1a1a1a;
  --border: rgba(255,255,255,0.08);
  --border-focus: rgba(255,255,255,0.2);
  --text: #e5e5e5;
  --text-secondary: #888;
  --text-muted: #555;
  --accent: #6C63FF;
  --accent-hover: #7b73ff;
  --accent-glow: rgba(108, 99, 255, 0.15);
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
  --font: system-ui, -apple-system, 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

/* === Layout === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* === Header / Nav === */
.tools-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.tools-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tools-header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tools-header .logo .icon { font-size: 1.5rem; }

.tools-header .back-link {
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.tools-header .back-link:hover { color: var(--text); }

/* === Hero / Section Header === */
.section-hero {
  text-align: center;
  padding: 60px 0 40px;
}

.section-hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text) 0%, #aaa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto;
}

/* === Cards Grid === */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  padding: 0 0 60px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
}

.tool-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.tool-card .card-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.tool-card .card-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.tool-card .card-en {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: -8px;
}

.tool-card .card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.tool-card .card-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: auto;
}

/* === Tool Page Layout === */
.tool-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 24px 60px;
}

.tool-page h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.tool-page .subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

/* === Upload Zone === */
.upload-zone {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  box-shadow: 0 0 32px var(--accent-glow);
}

.upload-zone .upload-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.upload-zone .upload-text {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.upload-zone .upload-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

/* === Form Controls === */
.form-group {
  margin-top: 20px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

select, input[type="number"], input[type="range"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* === Range Input === */
input[type="range"] {
  padding: 0;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
  border: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 12px var(--accent-glow);
}

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

.range-group input[type="range"] { flex: 1; }

.range-value {
  min-width: 48px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-glow);
  color: #fff;
}

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

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-block {
  width: 100%;
  margin-top: 20px;
}

/* === Progress Bar === */
.progress-container {
  margin-top: 20px;
  display: none;
}

.progress-container.active { display: block; }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* === File List === */
.file-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.file-item .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .file-size {
  color: var(--text-secondary);
  font-size: 0.8rem;
  white-space: nowrap;
}

.file-item .file-remove {
  color: var(--error);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 4px;
}

.file-item .file-remove:hover { opacity: 0.7; }

/* === Result Area === */
.result-area {
  margin-top: 24px;
  display: none;
}

.result-area.active { display: block; }

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.result-card .result-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.result-card .result-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.result-card .result-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.result-card.success .result-icon { color: var(--success); }
.result-card.error .result-icon { color: var(--error); }

/* === Preview === */
.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

.preview-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.preview-item .preview-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.preview-item img {
  max-height: 240px;
  margin: 0 auto;
  border-radius: 4px;
}

.preview-item .preview-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* === Toast / Alert === */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  max-width: 400px;
  animation: slideIn 0.3s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.toast.error { background: var(--error); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
.toast.warning { background: var(--warning); color: #000; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === Responsive === */
@media (max-width: 768px) {
  .section-hero h1 { font-size: 1.75rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .preview-grid { grid-template-columns: 1fr; }
  .tool-page { padding: 24px 16px 40px; }
  .upload-zone { padding: 32px 16px; }
}

/* === Footer === */
.tools-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* === Spinner === */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* === Responsive images in preview === */
@media (max-width: 480px) {
  .section-hero { padding: 40px 0 24px; }
  .section-hero h1 { font-size: 1.5rem; }
  .tool-card { padding: 20px; }
}
