:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --primary: #1f6feb;
  --border: #d7dde5;
  --danger: #b91c1c;
  --highlight: #f97316;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 24px 32px;
  background: #111827;
  color: white;
  border-bottom: 4px solid var(--primary);
}

header h1 {
  margin: 0;
  font-size: 24px;
}

header p {
  margin: 8px 0 0;
  color: #cbd5e1;
  font-size: 14px;
}

main {
  max-width: 1300px;
  margin: 24px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.card-title {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  background: #f8fafc;
}

.card-body { padding: 18px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #374151;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  background: white;
}

input:focus, select:focus {
  outline: 2px solid rgba(31, 111, 235, 0.22);
  border-color: var(--primary);
}

.field {
  margin-bottom: 14px;
}

.field.active-field label {
  color: var(--highlight);
}

.field.active-field input {
  border-color: var(--highlight);
  outline: 2px solid rgba(249, 115, 22, 0.20);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 13px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: white;
  transition: 0.15s ease;
}

button:hover { filter: brightness(0.94); }

.secondary {
  background: #374151;
  margin-top: 10px;
}

.library-btn {
  background: #0f766e;
  margin-bottom: 16px;
}

.library-panel {
  display: none;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.library-panel.open { display: block; }

.library-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 13px;
}

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

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

.library-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  padding: 10px;
  cursor: pointer;
  transition: 0.15s ease;
}

.library-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.library-card.active {
  border-color: var(--primary);
  outline: 2px solid rgba(31, 111, 235, 0.18);
}

.library-thumb {
  width: 100%;
  height: 95px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  margin-bottom: 8px;
}

.library-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  color: #1f2933;
}

.preview-wrap {
  min-height: 650px;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  font-size: 13px;
  color: var(--muted);
}

.svg-area {
  flex: 1;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(#eef2f7 1px, transparent 1px),
    linear-gradient(90deg, #eef2f7 1px, transparent 1px);
  background-size: 20px 20px;
}

svg#preview {
  width: 100%;
  height: 620px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.shape-line {
  fill: none;
  stroke: #111827;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.highlight-line {
  fill: none;
  stroke: var(--highlight);
  stroke-width: 5;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.center-line {
  stroke: #ef4444;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 8 5;
}

.dim-text {
  font-size: 12px;
  fill: #1f6feb;
  font-family: Arial, Helvetica, sans-serif;
}

.error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  margin-top: 8px;
  min-height: 18px;
}

.info-box {
  margin-top: 14px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #374151;
}

code {
  background: #eef2f7;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 12px;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  svg#preview { height: 460px; }
}
