:root {
  color-scheme: light;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #f5f7fb;
  --text: #1b1f23;
  --muted: #4b5563;
  --card: #ffffff;
  --border: #d1d5db;
  --panel-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --input-bg: #111827;
  --input-text: #ffffff;
  --drop-bg: #f9fafb;
  --drop-bg-active: #eef2ff;
  --output-bg: #f3f4f6;
  --button-bg: #e5e7eb;
  --button-text: #111827;
  --primary-bg: #2563eb;
  --primary-text: #ffffff;
  --success-bg: #16a34a;
  --success-text: #ffffff;
  --danger-bg: #ef4444;
  --danger-text: #ffffff;
}

body.dark {
  color-scheme: dark;
  --bg: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --card: #111827;
  --border: #374151;
  --panel-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  --input-bg: #1f2937;
  --input-text: #f9fafb;
  --drop-bg: #0b1220;
  --drop-bg-active: #1e293b;
  --output-bg: #0b1220;
  --button-bg: #1f2937;
  --button-text: #e5e7eb;
  --primary-bg: #3b82f6;
  --primary-text: #ffffff;
  --success-bg: #22c55e;
  --success-text: #ffffff;
  --danger-bg: #ef4444;
  --danger-text: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 40px;
}

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

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.icon-link {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--button-text);
  background: var(--button-bg);
  border: 1px solid var(--border);
  text-decoration: none;
}

.icon-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.header p {
  margin: 0;
  color: var(--muted);
}

.panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 20px;
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--panel-shadow);
}

.file-input {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.file-input input {
  display: none;
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  margin-left: auto;
  text-align: left;
  align-items: flex-start;
  min-width: 220px;
}

.workspace {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.preview-area {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--panel-shadow);
}

.area-title {
  font-weight: 600;
  color: var(--text);
}

.image-wrap {
  flex: 1;
  border: 1px dashed var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--drop-bg);
  min-height: 320px;
  position: relative;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.image-wrap.dragover {
  border-color: var(--primary-bg);
  background: var(--drop-bg-active);
}

.drop-zone::after {
  content: "拖拽图片到此处或在上方选择照片";
  position: absolute;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.drop-zone.has-image::after {
  display: none;
}

.image-wrap img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.image-wrap.output {
  background: var(--output-bg);
}

.actions {
  display: flex;
  gap: 12px;
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.inline-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

body.is-mobile .header {
  flex-direction: column;
  align-items: flex-start;
}

body.is-mobile .panel-row {
  flex-direction: column;
  align-items: stretch;
}

body.is-mobile .file-input {
  width: 100%;
  justify-content: center;
}

body.is-mobile .inline-actions {
  width: 100%;
  justify-content: space-between;
}

body.is-mobile .meta {
  margin-left: 0;
  width: 100%;
  align-items: flex-start;
  text-align: left;
}

body.is-mobile .workspace {
  grid-template-columns: 1fr;
}

body.is-mobile .preview-area .button {
  width: 100%;
}

.button {
  appearance: none;
  border: none;
  background: var(--button-bg);
  color: var(--button-text);
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.button.primary {
  background: var(--primary-bg);
  color: var(--primary-text);
}

.button.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.button.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--button-text);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.theme-track {
  position: relative;
  width: 64px;
  height: 32px;
  background: var(--button-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  box-sizing: border-box;
}

.theme-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}

.theme-thumb {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 24px;
  height: 24px;
  background: var(--card);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.theme-toggle input:checked + .theme-track .theme-thumb {
  transform: translateX(28px);
}

.button.disabled {
  pointer-events: none;
  opacity: 0.5;
}

@media (max-width: 720px) {
  .panel {
    align-items: flex-start;
  }

  .actions {
    flex-direction: column;
  }

  .inline-actions {
    width: 100%;
  }
}
