:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --line: #e2e2de;
  --text: #22211f;
  --muted: #7a7873;
  --accent: #2f6f4f;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
  display: flex; flex-direction: column;
}
header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
h1 { font-size: 16px; font-weight: 600; }
.spacer { flex: 1; }
.toggle {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.toggle.active { background: var(--text); border-color: var(--text); color: #fff; }
.total { font-weight: 600; margin-left: 12px; }
main { flex: 1; display: flex; min-height: 0; }
aside#palette {
  width: 220px; overflow-y: auto; background: var(--panel);
  border-right: 1px solid var(--line); padding: 8px;
}
.part {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.part:hover { border-color: var(--line); }
.part.active { border-color: var(--accent); background: #eef5f0; }
.part .price { color: var(--muted); white-space: nowrap; }
#stage { flex: 1; position: relative; min-width: 0; }
#canvas-wrap { position: absolute; inset: 0; }
#canvas-wrap canvas { display: block; }
#hint {
  position: absolute; left: 12px; bottom: 10px; color: var(--muted);
  font-size: 12px; pointer-events: none;
}
#spec { position: absolute; inset: 0; overflow: auto; background: var(--bg); padding: 24px; }
#spec table { width: 100%; max-width: 720px; border-collapse: collapse; background: var(--panel); }
#spec th, #spec td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
#spec th:nth-child(n+2), #spec td:nth-child(n+2) { text-align: right; }
#spec tfoot td { font-weight: 600; }
aside#chat {
  width: 300px; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
}
#chat-log { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 90%; padding: 8px 10px; border-radius: 10px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--text); color: #fff; }
.msg.agent { align-self: flex-start; background: var(--bg); }
.msg.error { align-self: flex-start; background: #fbeae8; color: #9c2b1f; }
#chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
#chat-input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
#chat-form button {
  border: none; background: var(--accent); color: #fff; border-radius: 6px;
  padding: 0 14px; cursor: pointer; font-size: 16px;
}
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #9c2b1f; color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 10;
}
.hidden { display: none !important; }
@media (max-width: 900px) {
  aside#palette { width: 160px; }
  aside#chat { position: fixed; right: 0; top: 0; bottom: 0; z-index: 5; }
}
