:root {
  --bg: #f3f0e9;
  --panel: #ffffff;
  --ink: #20242a;
  --muted: #61656c;
  --line: #cbc4b8;
  --accent: #1f6f59;
  --danger: #9f3329;
  --wood: #dec49e;
  --cut: #c94b35;
  --slot: #d9ecf2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: #20242a;
  color: #fff;
}

h1,
h2,
p {
  margin: 0;
}

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

.app-header p {
  margin-top: 4px;
  color: #d9e3e6;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

button,
.template-link {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.template-link {
  background: #46505a;
}

#downloadLink {
  background: #6a5b42;
}

.app-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.controls,
.workspace {
  min-width: 0;
}

.panel,
.workflow,
.preview-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.panel {
  padding: 12px;
  margin-bottom: 12px;
}

.panel h2,
.workflow h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

label {
  display: grid;
  grid-template-columns: 1fr 96px 28px;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--ink);
  font-weight: 700;
}

label + label {
  margin-top: 8px;
}

input {
  width: 96px;
  height: 30px;
  border: 1px solid #a9a9a9;
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
}

label span {
  color: var(--muted);
  font-weight: 400;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 10px;
}

#metrics,
#validation {
  color: var(--muted);
  line-height: 1.35;
}

#validation.is-error {
  color: var(--danger);
  font-weight: 700;
}

.preview-shell {
  height: calc(100vh - 220px);
  min-height: 460px;
  overflow: hidden;
}

#preview {
  width: 100%;
  height: 100%;
  display: block;
  background: #fbfbfb;
}

.workflow,
.export-fallback {
  margin-top: 12px;
  padding: 12px;
}

.workflow ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.workflow li + li {
  margin-top: 4px;
}

.export-fallback summary {
  cursor: pointer;
  font-weight: 700;
}

.export-fallback p {
  margin-top: 8px;
  color: var(--muted);
}

#dxfText {
  width: 100%;
  height: 180px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  resize: vertical;
}

#layerList {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

#layerList li + li {
  margin-top: 4px;
}

.layer-base {
  stroke: #2f6d3a;
}

.layer-front {
  stroke: #c94b35;
}

.layer-dovetail {
  stroke: #7b4bb0;
}

.layer-easing {
  stroke: #d08a21;
}

.layer-rebate {
  stroke: #30728a;
}

.layer-runner {
  stroke: #5c6974;
}

.layer-side {
  stroke: #0f7f8f;
}

.preview-vector {
  fill: none;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

.preview-fill {
  fill: var(--wood);
  stroke: #333;
  stroke-width: 1;
  opacity: 0.18;
  vector-effect: non-scaling-stroke;
}

.preview-label {
  fill: #222;
  font-size: 12px;
  font-family: Arial, Helvetica, sans-serif;
}

@media (max-width: 880px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .preview-shell {
    height: 520px;
  }
}
