/* ====== Reset & Base ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body > .navbar { flex-shrink: 0; }
.main-content { flex: 1; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select { font: inherit; }

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

/* ====== Navbar ====== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.nav-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.2rem; color: #1e293b;
}
.logo-icon { font-size: 1.4rem; }
.nav-links { display: flex; gap: 24px; }
.nav-links a {
  color: #64748b; font-weight: 500; font-size: 0.9rem;
  transition: color 0.2s; padding: 6px 0;
}
.nav-links a:hover { color: #4a6cf7; }
.nav-toggle { display: none; font-size: 1.5rem; color: #64748b; }

@media (max-width: 768px) {
  .nav-links { display: none; position: absolute; top: 60px; left: 0; right: 0;
    background: white; flex-direction: column; padding: 16px 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
}

/* ====== Page Routing ====== */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.main-content { padding: 32px 20px 80px; }

/* ====== Hero ====== */
.hero { text-align: center; margin: 48px 0 40px; }
.hero h1 { font-size: 2.4rem; font-weight: 800; background: linear-gradient(135deg, #4a6cf7, #7c3aed);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-sub { color: #64748b; font-size: 1.1rem; margin-top: 8px; }

/* ====== Tool Grid ====== */
.tool-grid {
  display: flex; flex-wrap: wrap;
  gap: 20px; margin: 24px 0;
}
.tool-grid .tool-card {
  min-width: 260px; max-width: 320px; flex: 1 1 280px;
}
.tool-card {
  background: white; border-radius: 16px; padding: 28px 24px;
  transition: all 0.2s; cursor: pointer;
  border: 1px solid #e2e8f0;
  height: 160px;
  display: flex; flex-direction: column; justify-content: center;
}
.tool-card:hover { border-color: #4a6cf7; box-shadow: 0 8px 24px rgba(74,108,247,0.12); transform: translateY(-2px); }
.tool-card .card-icon { font-size: 2rem; margin-bottom: 12px; }
.tool-card h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.tool-card p { color: #64748b; font-size: 0.85rem; line-height: 1.5; }
.doc-grid { }

/* ====== Page Header ====== */
.page-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 28px;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; }

/* ====== Tool Container ====== */
.tool-container {
  display: grid; grid-template-columns: 280px 1fr;
  gap: 20px; align-items: start;
}
@media (max-width: 900px) {
  .tool-container { grid-template-columns: 1fr; }
}

.tool-sidebar { background: white; border-radius: 12px; padding: 20px; border: 1px solid #e2e8f0; }
.tool-canvas-area { background: white; border-radius: 12px; padding: 20px; border: 1px solid #e2e8f0; }
.tool-result { margin-top: -80px; background: white; border-radius: 12px; padding: 24px; border: 1px solid #e2e8f0; }

.tool-controls { margin-bottom: 16px; }
.tool-controls label { display: block; font-size: 0.85rem; font-weight: 500; color: #475569; margin-bottom: 6px; }
.tool-controls input[type="range"] { width: 100%; accent-color: #4a6cf7; }

/* ====== Buttons ====== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 8px; font-weight: 600; font-size: 0.9rem;
  transition: all 0.2s; border: 1px solid transparent;
}
.btn-primary { background: #4a6cf7; color: white; }
.btn-primary:hover { background: #3b5de7; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: #f1f4f9; color: #475569; border-color: #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: transparent; color: #64748b; }
.btn-ghost:hover { background: #f1f4f9; }
.btn-sm { padding: 4px 12px; font-size: 0.8rem; }
.btn-lg { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; margin-top: 12px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ====== Tab ====== */
.tab-group { display: flex; gap: 4px; background: #f1f4f9; border-radius: 8px; padding: 4px; margin-bottom: 16px; }
.tab-btn {
  flex: 1; padding: 6px 12px; border-radius: 6px; font-size: 0.82rem; font-weight: 500;
  color: #64748b; transition: all 0.2s;
}
.tab-btn.active { background: white; color: #1e293b; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ====== Canvas ====== */
.canvas-wrapper {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: #f8fafc; border: 2px dashed #e2e8f0; border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 400px;
}
.canvas-wrapper canvas { max-width: 100%; max-height: 100%; touch-action: none; }
.canvas-placeholder {
  text-align: center; padding: 48px 20px; color: #94a3b8;
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 100%;
}
.canvas-placeholder .placeholder-icon { font-size: 3rem; margin-bottom: 12px; }
.canvas-placeholder p { margin-bottom: 12px; }
/* 删除图片按钮 */
.remove-image-btn {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px;
  border-radius: 50%; border: none;
  background: rgba(0,0,0,0.5); color: #fff;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 10;
  transition: background 0.2s;
  padding: 0;
}
.remove-image-btn:hover { background: rgba(220,38,38,0.8); }

/* 文件删除按钮 */
.remove-file-btn {
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%; border: none;
  background: #dc2626; color: #fff;
  font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  transition: background 0.2s, transform 0.15s;
}
.remove-file-btn:hover { background: #b91c1c; transform: scale(1.1); }
.canvas-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

/* ====== Color Picker ====== */
.color-picker { display: flex; gap: 6px; }
.color-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
  transition: all 0.2s;
}
.color-btn.active { border-color: #4a6cf7; box-shadow: 0 0 0 2px white, 0 0 0 4px #4a6cf7; }

/* ====== Progress Bar ====== */
.progress-bar {
  margin-top: 16px; position: relative; height: 32px;
  background: #f1f4f9; border-radius: 16px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(135deg, #4a6cf7, #7c3aed);
  transition: width 0.3s; border-radius: 16px; width: 0%;
}
.progress-bar span {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 0.8rem; font-weight: 600; color: #1e293b;
}

/* ====== Result ====== */
.result-image { max-height: 400px; margin: 12px auto; border-radius: 8px; cursor: zoom-in; }
.result-image:hover { opacity: 0.9; }
.result-controls { display: flex; gap: 12px; margin: 12px 0; }
.result-time { color: #94a3b8; font-size: 0.8rem; }

/* Lightbox 放大预览 */
.lightbox {
  display: none; position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 95vw; max-height: 95vh;
  border-radius: 4px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.5);
}
.lightbox-close {
  position: absolute; top: 20px; right: 30px;
  color: #fff; font-size: 28px;
  cursor: pointer;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
}

/* ====== Document Convert ====== */
.doc-convert-box { max-width: 100%; margin: 0 auto; }
.doc-convert-box .upload-zone { width: 100%; }
.upload-zone {
  border: 2px dashed #e2e8f0; border-radius: 16px; padding: 48px 24px;
  text-align: center; transition: all 0.2s; background: #fafbfc;
  aspect-ratio: 16 / 9;
  min-height: 400px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.upload-zone:hover { border-color: #4a6cf7; background: #f0f4ff; }
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-hint { font-size: 0.8rem; color: #94a3b8; margin: 4px 0 12px; }

/* ====== Form ====== */
.form-input {
  width: 100%; padding: 12px 16px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 1rem; color: #1e293b; transition: border-color 0.2s;
}
.form-input:focus { outline: none; border-color: #4a6cf7; box-shadow: 0 0 0 3px rgba(74,108,247,0.15); }
select.form-input { cursor: pointer; }
.form-group { margin: 16px 0; }
.form-group label { display: block; font-weight: 500; font-size: 0.85rem; color: #475569; margin-bottom: 6px; }
.form-group small { color: #94a3b8; font-size: 0.8rem; }

/* ====== File List ====== */
.file-list { margin-top: 12px; text-align: left; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #f8fafc; border-radius: 8px; margin: 4px 0;
  font-size: 0.85rem;
}
.file-info { margin-top: 12px; display: flex; align-items: center; gap: 8px; justify-content: center; }

/* ====== Preview Grid ====== */
.preview-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; margin-top: 16px;
}
.preview-grid img { border-radius: 8px; border: 1px solid #e2e8f0; }
.preset-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.preset-btn { font-size: 0.75rem; padding: 3px 8px; }

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: white; padding: 12px 24px; border-radius: 10px;
  font-weight: 500; font-size: 0.9rem; z-index: 1000;
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ====== Footer / ICP ====== */
.site-footer {
  text-align: center;
  padding: 32px 20px 40px;
  color: #94a3b8;
  font-size: 0.8rem;
}
.site-footer a {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.2s;
}
.site-footer a:hover {
  color: #4a6cf7;
}

/* ====== Responsive ====== */
@media (max-width: 600px) {
  .hero h1 { font-size: 1.6rem; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool-container { grid-template-columns: 1fr; }
}
