:root {
  --bg0: #0f1c17;
  --bg1: #1a3228;
  --panel: rgba(246, 241, 232, 0.94);
  --ink: #15241c;
  --muted: #5b6e64;
  --accent: #c45c26;
  --accent-2: #2f6f5e;
  --line: rgba(21, 36, 28, 0.12);
  --danger: #b42318;
  --ok: #1f6b4a;
  --radius: 18px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", serif;
  --font-body: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, #3d7a62 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #c45c26 0%, transparent 45%),
    linear-gradient(160deg, var(--bg0), var(--bg1));
}

.page {
  width: min(1680px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3.5rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.35fr) minmax(280px, 0.95fr);
  gap: 1.2rem;
  align-items: start;
}

.hero {
  color: #f6f1e8;
  margin-bottom: 1.5rem;
}

.brand {
  margin: 0 0 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.8rem;
  opacity: 0.85;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.2;
}

.sub {
  margin: 0.75rem 0 0;
  max-width: 44rem;
  color: rgba(246, 241, 232, 0.82);
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.6rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.files-panel,
.preview-panel {
  position: sticky;
  top: 1.25rem;
  max-height: calc(100vh - 2.5rem);
  overflow: auto;
}

.files-panel h2,
.config-panel .block h2,
.preview-panel h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--font-display);
}

.file-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: rgba(47, 111, 94, 0.12);
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 600;
}

.file-count.is-full {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.file-drop:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.file-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.file-list:empty {
  display: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.file-item-ext {
  flex: 0 0 auto;
  min-width: 2.4rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  background: rgba(47, 111, 94, 0.1);
  color: var(--accent-2);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: uppercase;
  line-height: 1.2;
}

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

.file-item-name {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-size {
  margin: 0.15rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.2;
}

.file-item-remove {
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.file-item-remove:hover {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.block + .block {
  margin-top: 1.3rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--line);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem 0.75rem;
}

.grid[hidden] {
  display: none;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.86rem;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
  line-height: 1.45;
}

.grid > .span-2 {
  grid-column: 1 / -1;
}

input[type="color"] {
  width: 100%;
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.2rem;
  background: #fff;
}

.file-drop {
  position: relative;
  border: 1.5px dashed rgba(47, 111, 94, 0.45);
  border-radius: 12px;
  padding: 1.1rem;
  text-align: center;
  color: var(--accent-2);
  background: rgba(47, 111, 94, 0.06);
  cursor: pointer;
}

.files-panel.is-dragover .file-drop {
  border-color: var(--accent-2);
  background: rgba(47, 111, 94, 0.14);
}

.file-drop.compact {
  padding: 0.85rem;
}

.file-drop input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.switch {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
}

.meta {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.file-error {
  margin: 0.55rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.4;
}

.file-error[hidden] {
  display: none;
}

.preview-wrap {
  grid-column: 1 / -1;
}

#image-preview {
  max-height: 96px;
  max-width: 220px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.preview-hint {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.canvas-frame {
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, #fbfaf7 0%, #f3efe6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  overflow: hidden;
  padding: 0.65rem;
}

#wm-preview {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(21, 36, 28, 0.08);
  min-height: 180px;
  object-fit: contain;
}

.preview-status {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.direction-presets {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.preset-label {
  font-size: 0.86rem;
  color: var(--muted);
}

.preset-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.preset-btns button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.preset-btns button:hover {
  border-color: rgba(47, 111, 94, 0.45);
}

.preset-btns button.active {
  background: rgba(47, 111, 94, 0.12);
  border-color: var(--accent-2);
  color: var(--accent-2);
  font-weight: 600;
}

.actions {
  margin-top: 1.4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 1rem;
}

button[type="submit"] {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.35rem;
  background: linear-gradient(135deg, var(--accent), #a8461b);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

button[type="submit"]:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button[type="submit"]:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.status {
  margin: 0;
  color: var(--ok);
  font-size: 0.9rem;
}

.error {
  margin: 0.8rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.progress-wrap {
  margin-top: 0.9rem;
  height: 8px;
  border-radius: 999px;
  background: rgba(21, 36, 28, 0.08);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.2s ease;
}

.site-footer {
  margin-top: 2.25rem;
  padding-top: 1.25rem;
  text-align: center;
  color: rgba(246, 241, 232, 0.62);
  font-size: 0.78rem;
  line-height: 1.6;
}

.site-footer p {
  margin: 0.15rem 0;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: rgba(246, 241, 232, 0.9);
  text-decoration: underline;
}

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: minmax(200px, 0.85fr) minmax(0, 1.4fr);
  }

  .preview-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
    order: -1;
  }
}

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

  .files-panel,
  .preview-panel {
    position: static;
    max-height: none;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .page {
    padding-top: 2rem;
  }
}
