:root {
  --ink: #111827;
  --muted: #5b6472;
  --line: #d7dde7;
  --panel: #ffffff;
  --soft: #f3f6fb;
  --input: #fff4c2;
  --accent: #1f6feb;
  --accent-soft: #e7f0ff;
  --ok: #137333;
  --warn: #a15c00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef2f7;
  color: var(--ink);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

.toolbar p,
.preview-header p,
.section-title span {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}

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

button {
  border: 1px solid #b9c4d4;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(430px, 520px) minmax(620px, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.input-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

.input-panel {
  padding: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-title h2,
.preview-header h2 {
  font-size: 18px;
}

.field-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.config-library {
  margin-top: 12px;
  padding: 12px;
  background: #f8fbff;
  border: 1px solid #dbe7f8;
}

.config-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.config-title h3 {
  font-size: 15px;
}

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

.config-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

.config-controls:last-child {
  grid-template-columns: 1fr auto auto auto;
}

.config-controls input,
.config-controls select {
  min-width: 0;
  border: 1px solid #c9d2df;
  background: #fff;
  padding: 8px 9px;
  font-size: 14px;
}

.field {
  display: grid;
  grid-template-columns: 92px 1fr 92px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--soft);
  border: 1px solid #e1e7f0;
}

.field label {
  font-size: 13px;
  color: var(--muted);
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 6px;
  align-items: center;
}

.control-row input,
.control-row select {
  width: 100%;
  min-width: 0;
  border: 1px solid #c9d2df;
  background: var(--input);
  padding: 8px 9px;
  font-size: 14px;
}

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

.hint-svg {
  width: 92px;
  height: 52px;
  background: #fff;
  border: 1px solid #dfe5ee;
}

.preview-panel {
  padding: 14px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.status {
  padding: 7px 10px;
  background: #e8f5ec;
  color: var(--ok);
  border: 1px solid #badcc5;
  font-size: 13px;
  white-space: nowrap;
}

.status.warn {
  background: #fff6e6;
  color: var(--warn);
  border-color: #f0cf9a;
}

.diagram-stage {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  margin-top: 12px;
  min-height: 600px;
}

#mainDrawing {
  display: block;
  width: 100%;
  min-width: 920px;
  height: 720px;
}

.part {
  stroke: #111;
  stroke-width: 8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.front-part {
  stroke: #111;
  stroke-width: 8;
  fill: #fff;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thin {
  stroke: #111;
  stroke-width: 3;
  fill: none;
}

.dim {
  stroke: #111;
  stroke-width: 2.4;
  fill: none;
}

.hole {
  fill: #111;
}

.measure {
  stroke: var(--accent);
  stroke-width: 6;
  fill: none;
  stroke-linecap: round;
}

.drawing-text {
  fill: #111;
  font-size: 42px;
}

.drawing-small {
  fill: #111;
  font-size: 34px;
}

.summary-panel {
  margin-top: 12px;
  background: var(--accent-soft);
  border: 1px solid #bcd3ff;
  padding: 12px;
}

.summary-panel h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.summary-panel dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin: 0;
}

.summary-panel dt {
  color: var(--muted);
  font-size: 12px;
}

.summary-panel dd {
  margin: 2px 0 0;
  font-weight: 700;
}

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

  #mainDrawing {
    min-width: 840px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
  }

  .toolbar,
  .preview-header,
  .section-title {
    display: block;
  }

  .toolbar-actions {
    margin-top: 12px;
  }

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

  .hint-svg {
    width: 100%;
  }

  .summary-panel dl {
    grid-template-columns: 1fr 1fr;
  }
}
