:root {
  --bg: #eef2f8;
  --panel: #ffffff;
  --text: #192232;
  --muted: #6d778a;
  --line: #d6dde9;
  --primary: #2b7bff;
  --primary-hover: #1f68df;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #eef2f8 0%, #e7edf7 100%);
  font: 14px/1.5 "Microsoft YaHei", sans-serif;
}

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 18px 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

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

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

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
}

.panel {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(22, 43, 90, 0.08);
  border: 1px solid #e4e9f3;
}

.controls {
  padding: 16px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.inline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

select,
.field input[type="file"],
.field input[type="number"],
.field input[type="range"] {
  width: 100%;
}

select,
.field input[type="number"] {
  border: 1px solid #ccd6e6;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

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

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 12px;
}

button {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
}

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

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

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

.secondary {
  background: #e8f0ff;
  color: #1b56bb;
  border-color: #c6dafc;
}

.ghost {
  background: #fff;
  color: #2f3f5f;
  border-color: #d8dfec;
}

.preview-panel {
  padding: 14px;
}

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

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

.stage {
  position: relative;
  width: 100%;
  min-height: 380px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #f4f7fc;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#previewCanvas {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  border-radius: 8px;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7f8aa2;
  font-size: 15px;
}

.status {
  position: relative;
  overflow: hidden;
  background: #f5f8ff;
  border: 1px solid #d7e3ff;
  border-radius: 8px;
  color: #2b3d66;
  padding: 8px 10px;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.status-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: #c9f7c3;
  transition: width 0.25s ease;
  z-index: 0;
}

.status-label {
  position: relative;
  z-index: 1;
}

.status.loading .status-fill {
  background: #c9f7c3;
}

.download {
  display: inline-block;
  margin-top: 8px;
  color: #1c63d8;
  text-decoration: none;
}

.download:hover {
  text-decoration: underline;
}

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

  .stage {
    min-height: 300px;
  }
}

/* mobile/tablet enhancement */
@media (max-width: 980px) {
  body { overflow: auto; }
  .app { padding: 12px; }
  .topbar { padding: 12px; border-radius: 12px; }
  .topbar h1 { font-size: 22px; }
  .layout { gap: 12px; }
  .controls, .preview-panel { padding: 12px; }
}
@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .two-col { grid-template-columns: 1fr; }
  .actions { flex-direction: column; }
  button { width: 100%; }
}

@media (min-width: 360px) and (max-width: 430px) {
  .app { padding: 10px; }
  .topbar { padding: 10px; }
  .topbar h1 { font-size: 19px; }
  .controls, .preview-panel { padding: 10px; }
  button, select, input { min-height: 42px; }
}
