:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --ink: #171d1a;
  --muted: #66716c;
  --line: #d8dfda;
  --panel: #ffffff;
  --panel-soft: #eef3ef;
  --green: #23745a;
  --green-dark: #15543f;
  --red: #d9362b;
  --gold: #b98321;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  max-width: 1240px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 0 22px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.04;
  font-weight: 760;
  letter-spacing: 0;
}

.status {
  min-height: 24px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.tool-pane,
.preview-pane {
  min-width: 0;
}

.mode-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mode-button,
.preset-button {
  border: 0;
  border-radius: 6px;
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 720;
}

.mode-button.is-active,
.preset-button.is-active {
  background: var(--panel);
  color: var(--green-dark);
  box-shadow: 0 1px 4px rgba(24, 34, 29, 0.1);
}

.auto-panel {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 14px;
  align-items: end;
  margin-top: 16px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-button {
  border: 1px solid var(--line);
  background: var(--panel);
}

.preset-button.is-active {
  border-color: rgba(35, 116, 90, 0.36);
}

.manual-panel {
  margin-top: 16px;
}

.is-hidden {
  display: none !important;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 224px;
  padding: 28px;
  border: 2px dashed #aebbb4;
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--green);
  background: #f8fbf8;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  display: inline-grid;
  place-items: center;
  width: 72px;
  height: 88px;
  border: 2px solid var(--green);
  border-radius: 6px;
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0;
}

.drop-title {
  font-size: 22px;
  font-weight: 720;
}

.drop-count {
  color: var(--muted);
  font-size: 14px;
}

.file-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  flex: 0 0 auto;
  color: var(--muted);
}

.settings-grid {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

.field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 116, 90, 0.14);
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.toggle input {
  accent-color: var(--green);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 12px;
  margin-top: 22px;
}

.primary,
.secondary,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 46px;
  cursor: pointer;
  text-decoration: none;
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  font-weight: 720;
}

.primary {
  background: var(--green);
  color: white;
}

.primary:hover {
  background: var(--green-dark);
}

.primary:disabled,
.secondary.disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 28px;
  line-height: 1;
}

.preview-frame {
  display: grid;
  place-items: center;
  min-height: min(72vh, 760px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #edf1ee 25%, transparent 25%),
    linear-gradient(-45deg, #edf1ee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1ee 75%),
    linear-gradient(-45deg, transparent 75%, #edf1ee 75%);
  background-color: #fbfcfb;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  overflow: auto;
}

.preview-frame img {
  display: none;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 18px 48px rgba(24, 34, 29, 0.16);
}

.preview-frame.has-image img {
  display: block;
}

.empty-preview {
  display: grid;
  place-items: center;
  width: min(340px, 70vw);
  aspect-ratio: 4 / 3;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
  background: rgba(255, 255, 255, 0.78);
  font-size: 38px;
  font-weight: 850;
  letter-spacing: 0;
}

.preview-frame.has-image .empty-preview {
  display: none;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .auto-panel {
    grid-template-columns: 1fr;
  }

  .preview-frame {
    min-height: 360px;
  }
}
