:root {
  --bg: #eff2f8;
  --panel: #ffffff;
  --line: #dce3ef;
  --text: #1f2b3d;
  --muted: #6d7790;
  --primary: #2a6df6;
  --primary-hover: #1f5fe2;
  --secondary: #10a37f;
  --danger: #d64545;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #f7f9ff 0%, var(--bg) 56%);
  overflow: hidden;
}

.app {
  height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.layout {
  margin-top: 18px;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 14px;
  color: var(--muted);
}

input[type="file"],
input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #f8fafd;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

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

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

.switch-line {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.switch-line input {
  width: 18px;
  height: 18px;
}

.group {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

button {
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
}

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

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

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

.secondary {
  background: var(--secondary);
  color: #fff;
}

.ghost {
  background: #f0f4ff;
  color: #36518f;
  border: 1px solid var(--line);
}

.status-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcff;
}

.status-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.progress-wrap {
  margin-top: 8px;
  height: 10px;
  border-radius: 999px;
  background: #e6ecfa;
  overflow: hidden;
}

.progress {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a6df6 0%, #6aa4ff 100%);
  transition: width 0.25s ease;
}

.error {
  min-height: 18px;
  margin-top: 8px;
  color: var(--danger);
  font-size: 13px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-head h2 {
  margin: 0;
  font-size: 18px;
}

.preview-head span {
  color: var(--muted);
  font-size: 13px;
}

.preview-frame {
  position: relative;
  width: 66%;
  max-width: none;
  aspect-ratio: 1242 / 1660;
  border-radius: 0;
  border: 1px solid var(--line);
  background: #eef2f9;
  overflow: hidden;
  margin: 0 auto;
}

.preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: #8895af;
  cursor: pointer;
  z-index: 4;
}

.preview-nav-left {
  left: 8px;
}

.preview-nav-right {
  right: 8px;
}

.preview-nav-icon {
  font-size: 30px;
  line-height: 1;
}

.preview-nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(130, 145, 176, 0.35);
}

.preview-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

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

  .preview-frame {
    width: min(82%, 440px);
  }
}

@media (max-width: 640px) {
  .app {
    padding: 14px;
    overflow: auto;
  }

  .topbar {
    padding: 14px;
  }

  .topbar h1 {
    font-size: 20px;
  }

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

  .two-col {
    grid-template-columns: 1fr;
  }

  .preview-frame {
    width: 100%;
  }
}
