:root {
  color-scheme: light;
  --bg: #f5f2ec;
  --surface: #fffdf8;
  --line: #d8d0c2;
  --text: #221f1b;
  --muted: #746b5f;
  --accent: #1f6f5b;
  --accent-dark: #155140;
  --shadow: 0 18px 40px rgba(54, 45, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.primary:not(:disabled):hover {
  background: var(--accent-dark);
}

.ghost {
  background: transparent;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.workspace {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

p,
.dropzone span,
.preview-head span {
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  border: 1px dashed #aaa091;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #eef7f3;
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e6f0ec;
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-head,
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.image-list {
  display: grid;
  gap: 10px;
  min-height: 320px;
  max-height: 62vh;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.image-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  background: #eee8df;
}

.item-meta {
  min-width: 0;
}

.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.item-size {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.item-tools {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.item-tools button {
  min-width: 34px;
  min-height: 32px;
  padding: 0 8px;
}

.preview-panel {
  min-height: 620px;
  overflow: hidden;
}

.preview-head {
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.canvas-wrap {
  position: relative;
  min-height: 560px;
  max-height: 72vh;
  overflow: auto;
  background:
    linear-gradient(45deg, #ece5dc 25%, transparent 25%),
    linear-gradient(-45deg, #ece5dc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ece5dc 75%),
    linear-gradient(-45deg, transparent 75%, #ece5dc 75%);
  background-color: #faf8f3;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
  cursor: grab;
  touch-action: none;
}

canvas.dragging-watermark {
  cursor: grabbing;
}

.empty-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.settings {
  display: grid;
  gap: 14px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.field-group {
  display: grid;
  gap: 12px;
}

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

.field.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--text);
}

.field input:not([type="checkbox"]):not([type="color"]),
.field select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.field input[type="color"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

.file-field input {
  padding: 8px;
}

.watermark-preview {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.watermark-preview img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #ece5dc 25%, transparent 25%),
    linear-gradient(-45deg, #ece5dc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ece5dc 75%),
    linear-gradient(-45deg, transparent 75%, #ece5dc 75%);
  background-color: #faf8f3;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.watermark-preview span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.segmented button.active {
  background: #dfece7;
  color: var(--accent-dark);
  font-weight: 700;
}

.hidden {
  display: none;
}

@media (max-width: 1100px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .image-list {
    max-height: none;
  }
}

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 130px;
  }

  h1 {
    font-size: 24px;
  }
}
