* {
  box-sizing: border-box;
}

:root {
  --bg: #eef3ee;
  --panel: #ffffff;
  --soft: #f7faf6;
  --line: #d4ddd2;
  --ink: #17201b;
  --muted: #657164;
  --green: #315f46;
  --orange: #e97950;
  --shadow: 0 18px 55px rgba(33, 50, 38, 0.12);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #91a48f;
}

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

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

.danger {
  color: #a33b27;
}

.wide {
  width: 100%;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
}

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

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.2;
}

.brand p,
.editor-head p,
.note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: #405044;
  font-size: 13px;
  white-space: nowrap;
}

.layout {
  height: calc(100vh - 78px);
  min-height: 650px;
  display: grid;
  grid-template-columns: 286px minmax(480px, 1fr) 360px;
  gap: 14px;
  padding: 14px;
}

.panel,
.editor {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  overflow: auto;
  padding: 12px;
}

section {
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

section:last-child {
  margin-bottom: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 16px;
}

.upload {
  min-height: 138px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  border: 1.5px dashed #9db39b;
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  cursor: pointer;
}

.upload input {
  display: block;
  width: min(230px, 92%);
  color: var(--ink);
}

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

.status {
  margin-top: 8px;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.status.error {
  color: #a33b27;
}

.image-thumb {
  display: none;
  width: 100%;
  max-height: 150px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.image-thumb.visible {
  display: block;
}

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

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

input[type="number"] {
  width: 100%;
  height: 38px;
  margin-top: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  background: #fff;
  color: var(--ink);
}

.actions {
  display: grid;
  gap: 8px;
}

.editor {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.toolbar,
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-wrap {
  flex: 1;
  min-height: 0;
}

#planCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #f8faf8;
  cursor: crosshair;
}

.right {
  display: flex;
  flex-direction: column;
}

.three-view {
  height: 310px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #edf2ec;
}

.three-view canvas {
  display: block;
}

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

.template-grid button {
  min-width: 0;
  padding: 0 6px;
  font-size: 13px;
}

.row {
  margin-top: 10px;
}

.row button {
  flex: 1;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 280px 1fr;
    height: auto;
  }

  .right {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: stretch;
  }

  .canvas-wrap {
    height: 620px;
  }
}

@media (max-width: 820px) {
  .topbar,
  .editor-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout,
  .right {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    height: 520px;
  }
}
