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

:root {
  --primary: #4F46E5;
  --primary-light: #6366F1;
  --primary-dark: #4338CA;
  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1E293B;
  --text: #1E293B;
  --text-light: #64748B;
  --text-sidebar: #CBD5E1;
  --text-sidebar-active: #FFFFFF;
  --border: #E2E8F0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
  font-size: 1.4rem;
  color: #fff;
  margin-bottom: 4px;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-sidebar);
  opacity: 0.7;
}

.nav {
  flex: 1;
  padding: 12px 0;
}

.nav-group {
  margin-bottom: 4px;
}

.nav-label {
  display: block;
  padding: 8px 20px 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sidebar);
  opacity: 0.5;
}

.nav-item {
  display: block;
  width: 100%;
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-sidebar);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  font-family: inherit;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}

.nav-item.active {
  background: rgba(79,70,229,0.2);
  color: var(--text-sidebar-active);
  border-left-color: var(--primary-light);
}

.sidebar-footer {
  padding: 16px 20px;
  font-size: 0.7rem;
  color: var(--text-sidebar);
  opacity: 0.5;
  border-top: 1px solid rgba(255,255,255,0.08);
  line-height: 1.8;
}

/* Menu Toggle */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  background: var(--bg-sidebar);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Main */
.main {
  flex: 1;
  margin-left: 260px;
  padding: 40px;
  max-width: 900px;
  width: 100%;
}

.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
}

.tool-panel h2 {
  font-size: 1.8rem;
  margin-bottom: 4px;
  color: var(--text);
}

.tool-desc {
  color: var(--text-light);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

/* Form elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  background: var(--bg-card);
  transition: border-color var(--transition);
  resize: vertical;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

select {
  width: auto;
  font-family: inherit;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  font-weight: 500;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

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

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

.btn-small {
  padding: 6px 14px;
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.btn-small:hover {
  background: var(--border);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(79,70,229,0.03);
}

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

.upload-zone p {
  color: var(--text-light);
  margin-bottom: 16px;
}

/* Image preview */
.image-preview {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.preview-row {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}

.preview-box {
  flex: 1;
  text-align: center;
}

.preview-box h4 {
  margin-bottom: 8px;
  color: var(--text-light);
  font-size: 0.85rem;
}

.preview-box img {
  max-width: 100%;
  max-height: 250px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.preview-box p {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-light);
}

.compress-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.compress-controls label {
  font-size: 0.88rem;
  color: var(--text-light);
}

.compress-controls input[type="range"] {
  width: 140px;
}

.compress-controls input[type="number"] {
  width: 80px;
  padding: 6px 10px;
}

/* Control row */
.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Crop */
.crop-workspace {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.crop-container {
  position: relative;
  display: inline-block;
  user-select: none;
  max-width: 100%;
  border-radius: var(--radius-sm);
  cursor: crosshair;
}

.crop-container canvas {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-sm);
}

.crop-info {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-light);
}

/* QR result */
.qr-result {
  text-align: center;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.qr-result img {
  display: block;
  margin: 0 auto 16px;
  border-radius: var(--radius-sm);
}

/* Result box */
.result-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
}

.result-box span {
  flex: 1;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 1.1rem;
  word-break: break-all;
}

.pw-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: all 0.3s;
}

/* Stats row */
.stats-row {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-light);
}

.stats-row strong {
  color: var(--text);
}

/* Message */
.msg {
  font-size: 0.88rem;
  min-height: 20px;
}

.msg.success { color: #059669; }
.msg.error { color: #DC2626; }

/* Color tools */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.color-picker-row input[type="color"] {
  width: 60px; height: 60px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}

.color-preview {
  width: 80px; height: 80px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
}

.color-values {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-row {
  display: flex;
  gap: 8px;
}

.copy-row input {
  flex: 1;
  font-size: 0.95rem;
}

/* Ad slot */
.ad-slot {
  margin-top: 40px;
  padding: 40px;
  text-align: center;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-sidebar);
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.88rem;
  z-index: 999;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .main {
    margin-left: 0;
    padding: 20px;
    padding-top: 64px;
  }

  .preview-row {
    flex-direction: column;
  }

  .compress-controls {
    flex-direction: column;
    align-items: flex-start;
  }
}
