:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #5e6b78;
  --line: #d9e1ea;
  --accent: #0f8b8d;
  --accent-dark: #0a6f71;
  --warm: #f2b84b;
  --danger: #b3261e;
  --shadow: 0 18px 50px rgba(23, 33, 43, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    Arial,
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(242, 184, 75, 0.16), transparent 30%),
    var(--bg);
}

button,
input {
  font: inherit;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1360px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
}

.controls,
.preview-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(217, 225, 234, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), #2a5f9e);
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

.brand p,
.preview-topbar p,
.hint,
.scale,
.status,
.file-picker small {
  color: var(--muted);
}

.brand p {
  margin-top: 4px;
  font-size: 13px;
}

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

label,
.row-label {
  font-size: 14px;
  font-weight: 700;
}

.row-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-label span {
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.file-picker {
  display: flex;
  min-height: 78px;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px dashed #9fb0c1;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
}

.file-picker:hover {
  border-color: var(--accent);
  background: #f3fbfb;
}

.file-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.file-picker strong,
.file-picker small {
  display: block;
}

.file-picker small {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
}

input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.14);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: auto;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

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

#downloadAll {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

#downloadAll:hover:not(:disabled) {
  background: var(--accent-dark);
}

.status {
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.35;
}

.status.error {
  color: var(--danger);
  border-color: rgba(179, 38, 30, 0.3);
  background: rgba(179, 38, 30, 0.06);
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
}

.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.preview-topbar p {
  margin-top: 3px;
  font-size: 13px;
}

.preview-nav {
  display: grid;
  grid-template-columns: 42px minmax(60px, auto) 42px;
  align-items: center;
  gap: 8px;
}

.preview-nav button {
  width: 42px;
  min-height: 36px;
  font-size: 18px;
}

#imageCounter {
  min-width: 60px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.canvas-wrap {
  display: grid;
  min-height: 360px;
  place-items: center;
  padding: 18px;
  overflow: auto;
  background:
    linear-gradient(45deg, #edf2f7 25%, transparent 25%),
    linear-gradient(-45deg, #edf2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf2f7 75%),
    linear-gradient(-45deg, transparent 75%, #edf2f7 75%);
  background-color: #f8fafc;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

canvas {
  display: block;
  width: min(100%, 1080px);
  height: auto;
  max-height: calc(100vh - 150px);
  border: 1px solid rgba(23, 33, 43, 0.12);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(23, 33, 43, 0.12);
}

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

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .controls {
    gap: 16px;
    padding: 16px;
  }

  .preview-topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .preview-nav {
    width: 100%;
    grid-template-columns: 42px 1fr 42px;
  }

  .canvas-wrap {
    min-height: 300px;
    padding: 12px;
  }

  canvas {
    max-height: 68vh;
  }
}
