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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
}

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

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

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

.logo i {
  color: var(--danger);
  font-size: 1.5rem;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav a.active { color: var(--primary); }
.nav a:hover {
  background: var(--gray-100);
  color: var(--primary);
}

/* Hero */
.hero {
  text-align: center;
  padding: 48px 0 32px;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.hero p {
  color: var(--gray-500);
  font-size: 1.05rem;
  margin-bottom: 24px;
}

.search-box {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

.search-box i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}

.search-box input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  border: 2px solid var(--gray-200);
  border-radius: 50px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

.search-box input:focus {
  border-color: var(--primary);
}

/* Tool Categories */
.category {
  margin-bottom: 40px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gray-200);
}

.category-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-800);
}

.category-header i {
  font-size: 1.2rem;
  color: var(--primary);
}

/* Tool Cards Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.tool-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card:active {
  transform: translateY(0);
}

.tool-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.tool-card .icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  background: var(--primary-light);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--primary);
  transition: all 0.25s;
}

.tool-card:hover .icon {
  background: var(--primary);
  color: #fff;
}

.tool-card h3 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
}

.tool-card p {
  font-size: 0.78rem;
  color: var(--gray-400);
  line-height: 1.4;
}

.tool-card .fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--gray-300);
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.tool-card:hover .fav-btn {
  opacity: 1;
}

.tool-card .fav-btn.active {
  color: var(--secondary);
  opacity: 1;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

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

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

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header h2 i {
  color: var(--primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--gray-400);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-body {
  padding: 24px;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: var(--gray-50);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone i {
  font-size: 3rem;
  color: var(--gray-300);
  margin-bottom: 16px;
  transition: color 0.25s;
}

.drop-zone:hover i,
.drop-zone.dragover i {
  color: var(--primary);
}

.drop-zone p {
  color: var(--gray-600);
  margin-bottom: 8px;
  font-size: 1rem;
}

.drop-zone .drop-hint {
  font-size: 0.85rem;
  color: var(--gray-400);
  margin-bottom: 16px;
}

.drop-zone.loading {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}
.drop-zone.has-files {
  display: none;
}

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

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

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

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

.btn-success:hover {
  background: #059669;
  box-shadow: var(--shadow-md);
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-outline {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

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

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

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

.file-item i {
  font-size: 1.2rem;
}

.file-item .file-info {
  flex: 1;
  min-width: 0;
}

.file-item .file-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item .file-size {
  font-size: 0.78rem;
  color: var(--gray-400);
}

.file-item .file-remove {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.file-item .file-remove:hover {
  background: var(--gray-200);
  color: var(--danger);
}

/* Tool Controls */
.tool-controls {
  margin: 16px 0;
  padding: 16px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}

.tool-controls label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--gray-700);
}

.tool-controls input[type="text"],
.tool-controls input[type="number"],
.tool-controls input[type="password"],
.tool-controls select,
.tool-controls textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.tool-controls input:focus,
.tool-controls select:focus,
.tool-controls textarea:focus {
  border-color: var(--primary);
}

.tool-controls textarea {
  min-height: 120px;
  resize: vertical;
}

.tool-controls .form-group {
  margin-bottom: 12px;
}

.tool-controls .notice {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  line-height: 1.5;
}
.tool-controls .notice-warning {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
}
.tool-controls .notice-info {
  background: #dbeafe;
  border: 1px solid #3b82f6;
  color: #1e40af;
}
.tool-controls .notice i {
  margin-right: 6px;
}
.tool-controls .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tool-controls .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-controls .checkbox-group label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Action Bar */
.action-bar {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Progress */
.progress-bar {
  margin-top: 16px;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}

/* Preview Area */
.preview-area {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.preview-area img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: transform 0.2s;
}

.preview-area img:hover {
  transform: scale(1.05);
}

/* Result Area */
.result-area {
  margin-top: 16px;
}

.result-area .result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.result-area .result-item i {
  color: var(--success);
  font-size: 1.2rem;
}

/* Footer */
.footer {
  background: #fff;
  border-top: 1px solid var(--gray-200);
  padding: 32px 0;
  text-align: center;
  margin-top: 40px;
}

.footer p {
  color: var(--gray-400);
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.footer a {
  color: var(--gray-400);
  text-decoration: none;
}
.footer a:hover {
  text-decoration: underline;
}
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--gray-400);
}
.footer-row a { margin: 0 6px; }
.footer-hr {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 12px 0;
}

/* Contact overlay */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.overlay.active {
  display: flex;
}
.overlay-content {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  position: relative;
  max-width: 90vw;
}
.overlay-content img {
  max-width: 300px;
  height: auto;
  display: block;
}
.overlay-content p {
  margin-top: 12px;
  color: var(--gray-500);
  font-size: 0.9rem;
}
.overlay-close {
  position: absolute;
  top: 8px;
  right: 16px;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
}
.overlay-close:hover {
  color: var(--gray-600);
}

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  box-shadow: var(--shadow-md);
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 50;
}

.back-to-top.visible {
  display: flex;
}

.back-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

/* No results */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.no-results i {
  font-size: 3rem;
  margin-bottom: 16px;
  color: var(--gray-300);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 2000;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow-lg);
}

/* Color swatch for watermark/sign */
.color-picker-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-group input[type="color"] {
  width: 40px;
  height: 40px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

/* Scrollbar */
.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* Responsive */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.6rem; }
  .hero p { font-size: 0.95rem; }
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .tool-card { padding: 16px 12px; }
  .tool-card .icon { width: 40px; height: 40px; font-size: 1.2rem; }
  .tool-card h3 { font-size: 0.85rem; }
  .modal-content { max-height: 85vh; }
  .modal-body { padding: 16px; }
  .tool-controls .form-row { grid-template-columns: 1fr; }
  .header .container { height: 56px; }
  .logo span { display: none; }
}

@media (max-width: 480px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tool-card { padding: 12px 8px; }
  .tool-card .icon { width: 36px; height: 36px; font-size: 1rem; margin-bottom: 8px; }
  .tool-card h3 { font-size: 0.8rem; }
  .drop-zone { padding: 32px 16px; }
}

/* Page Reorder specific */
.sortable-list {
  list-style: none;
  padding: 0;
}

.sortable-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: grab;
  user-select: none;
}

.sortable-list li:active {
  cursor: grabbing;
}

.sortable-list li .drag-handle {
  color: var(--gray-400);
  cursor: grab;
}

.sortable-list li.dragging {
  opacity: 0.5;
}

/* Range slider */
.tool-controls input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.range-value {
  display: inline-block;
  font-weight: 700;
  color: var(--primary);
  min-width: 30px;
  text-align: center;
}

/* Help text */
.help-text {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 4px;
}

/* Inline control groups */
.control-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-inline label {
  margin-bottom: 0;
}

/* Tab style for split modes */
.tab-group {
  display: flex;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.tab-group .tab {
  flex: 1;
  padding: 10px 16px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: all 0.2s;
}

.tab-group .tab:not(:last-child) {
  border-right: 1px solid var(--gray-300);
}

.tab-group .tab.active {
  background: var(--primary);
  color: #fff;
}