:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #5c6b7c;
  --line: #dbe1e8;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --danger: #c4432b;
  --ok: #1d7a46;
  --radius: 10px;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.9rem; }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.2rem 1.6rem 0.8rem;
  max-width: 1400px;
  margin: 0 auto;
}
.kicker {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lede { margin: 0.3rem 0 0; color: var(--muted); max-width: 60ch; }
.credit { margin: 0.35rem 0 0; font-size: 0.8rem; color: var(--muted); }
.credit a { color: var(--accent); text-decoration: none; }
.credit a:hover { text-decoration: underline; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

main { max-width: 1400px; margin: 0 auto; padding: 0 1.6rem 2rem; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
  margin: 0.8rem 0 1rem;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
}
.metric span { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric strong { font-size: 1.05rem; }
.metric strong.bad { color: var(--danger); }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(380px, 1.1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel.sticky { position: static; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.eyebrow {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.6rem; }
input[type="text"], input[type="number"], select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.42rem 0.55rem;
  font: inherit;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 7px;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.setting-grid { display: grid; gap: 0.6rem; }
.setting-grid.two { grid-template-columns: 1fr 1fr; }
.setting-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.setting-grid.compact label { margin-bottom: 0.1rem; }
.setting-grid label { margin-bottom: 0.2rem; }

.help { font-size: 0.8rem; color: var(--muted); margin: 0.5rem 0 0; }
.help.prominent {
  background: #eef4fd;
  border: 1px solid #d4e3f8;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: #2c4a75;
  margin-bottom: 0.7rem;
}

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}
button:hover { border-color: #b9c4d1; background: #f6f8fb; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button.primary:hover { background: #1a5fd0; }
button.secondary { background: #f2f5f9; }
button.small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
button:disabled { opacity: 0.4; cursor: default; }

/* rows editor */
.rows { display: flex; flex-direction: column; gap: 0.7rem; }
.row-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  background: #fbfcfe;
}
.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  font-size: 0.88rem;
}
.row-tag {
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  margin-left: 0.3rem;
  vertical-align: 1px;
}
.row-buttons { display: flex; gap: 0.3rem; }
button.mini {
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 6px;
}
button.mini.danger { color: var(--danger); }
button.mini.add { color: var(--accent); border-style: dashed; }

.dia-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.55rem;
}
.dia-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}
.dia-chip input {
  width: 4.1rem;
  border: none;
  margin: 0;
  border-radius: 0;
  padding: 0.28rem 0.1rem 0.28rem 0.45rem;
  background: transparent;
}
.chip-x {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0 0.4rem;
  font-size: 0.9rem;
}
.chip-x:hover { color: var(--danger); background: transparent; border: none; }

/* advanced details */
details.advanced summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
}
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced .details-body { margin-top: 0.8rem; }

/* export */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.export-grid .primary { grid-column: 1 / -1; }
.notices { display: flex; flex-direction: column; gap: 0.35rem; }
.notice {
  margin: 0;
  font-size: 0.8rem;
  border-radius: 7px;
  padding: 0.4rem 0.6rem;
  background: #fdf2ec;
  border: 1px solid #f3d5c3;
  color: #8a3e1d;
}
.notice.ok {
  background: #eef8f0;
  border-color: #cfe8d6;
  color: var(--ok);
}
.status { font-size: 0.8rem; color: var(--muted); margin: 0.6rem 0 0; }

/* preview */
.preview-panel.sticky { position: sticky; top: 0.8rem; }
.preview-heading { margin-bottom: 0.4rem; }
.preview-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.55rem; }
.preview-tabs button { padding: 0.3rem 0.75rem; font-size: 0.8rem; border-radius: 999px; }
.preview-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.canvas-holder {
  height: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #fdfefe, #eef2f6);
}
.canvas-holder canvas { width: 100%; height: 100%; display: block; }

.layout-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.8rem 0 0.35rem;
}
.layout-heading span { font-size: 0.72rem; color: var(--muted); }
.svg-holder {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.3rem;
}
.svg-holder svg { width: 100%; display: block; }

.svg-plate { fill: #f4f6f9; stroke: #8fa0b3; stroke-width: 0.6; }
.svg-hole { fill: #fff; stroke: #4a5b6e; stroke-width: 0.5; }
.svg-cross { stroke: #a95c22; fill: none; opacity: 0.85; }
.svg-socket { fill: #dfe6ee; stroke: #7c8ea0; stroke-width: 0.4; }
.svg-socket-inner { fill: #fff; stroke: #7c8ea0; stroke-width: 0.3; }
.svg-dia { font-size: 5.5px; text-anchor: middle; fill: #33414f; font-family: inherit; }
.svg-rowlabel { font-size: 5px; text-anchor: end; fill: #a95c22; font-family: inherit; }

footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.6rem 1.4rem;
  color: var(--muted);
  font-size: 0.78rem;
}
:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #5c6b7c;
  --line: #dbe1e8;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --danger: #c4432b;
  --ok: #1d7a46;
  --radius: 10px;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.9rem; }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.2rem 1.6rem 0.8rem;
  max-width: 1400px;
  margin: 0 auto;
}
.kicker {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lede { margin: 0.3rem 0 0; color: var(--muted); max-width: 60ch; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

main { max-width: 1400px; margin: 0 auto; padding: 0 1.6rem 2rem; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
  margin: 0.8rem 0 1rem;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
}
.metric span { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric strong { font-size: 1.05rem; }
.metric strong.bad { color: var(--danger); }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(380px, 1.1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel.sticky { position: static; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.eyebrow {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.6rem; }
input[type="text"], input[type="number"], select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.42rem 0.55rem;
  font: inherit;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 7px;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.setting-grid { display: grid; gap: 0.6rem; }
.setting-grid.two { grid-template-columns: 1fr 1fr; }
.setting-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.setting-grid.compact label { margin-bottom: 0.1rem; }
.setting-grid label { margin-bottom: 0.2rem; }

.help { font-size: 0.8rem; color: var(--muted); margin: 0.5rem 0 0; }
.help.prominent {
  background: #eef4fd;
  border: 1px solid #d4e3f8;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: #2c4a75;
  margin-bottom: 0.7rem;
}

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}
button:hover { border-color: #b9c4d1; background: #f6f8fb; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button.primary:hover { background: #1a5fd0; }
button.secondary { background: #f2f5f9; }
button.small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
button:disabled { opacity: 0.4; cursor: default; }

/* rows editor */
.rows { display: flex; flex-direction: column; gap: 0.7rem; }
.row-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  background: #fbfcfe;
}
.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  font-size: 0.88rem;
}
.row-tag {
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  margin-left: 0.3rem;
  vertical-align: 1px;
}
.row-buttons { display: flex; gap: 0.3rem; }
button.mini {
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 6px;
}
button.mini.danger { color: var(--danger); }
button.mini.add { color: var(--accent); border-style: dashed; }

.dia-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.55rem;
}
.dia-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}
.dia-chip input {
  width: 4.1rem;
  border: none;
  margin: 0;
  border-radius: 0;
  padding: 0.28rem 0.1rem 0.28rem 0.45rem;
  background: transparent;
}
.chip-x {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0 0.4rem;
  font-size: 0.9rem;
}
.chip-x:hover { color: var(--danger); background: transparent; border: none; }

/* advanced details */
details.advanced summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
}
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced .details-body { margin-top: 0.8rem; }

/* export */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.export-grid .primary { grid-column: 1 / -1; }
.notices { display: flex; flex-direction: column; gap: 0.35rem; }
.notice {
  margin: 0;
  font-size: 0.8rem;
  border-radius: 7px;
  padding: 0.4rem 0.6rem;
  background: #fdf2ec;
  border: 1px solid #f3d5c3;
  color: #8a3e1d;
}
.notice.ok {
  background: #eef8f0;
  border-color: #cfe8d6;
  color: var(--ok);
}
.status { font-size: 0.8rem; color: var(--muted); margin: 0.6rem 0 0; }

/* preview */
.preview-panel.sticky { position: sticky; top: 0.8rem; }
.preview-heading { margin-bottom: 0.4rem; }
.preview-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.55rem; }
.preview-tabs button { padding: 0.3rem 0.75rem; font-size: 0.8rem; border-radius: 999px; }
.preview-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.canvas-holder {
  height: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #fdfefe, #eef2f6);
}
.canvas-holder canvas { width: 100%; height: 100%; display: block; }

.layout-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.8rem 0 0.35rem;
}
.layout-heading span { font-size: 0.72rem; color: var(--muted); }
.svg-holder {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.3rem;
}
.svg-holder svg { width: 100%; display: block; }

.svg-plate { fill: #f4f6f9; stroke: #8fa0b3; stroke-width: 0.6; }
.svg-hole { fill: #fff; stroke: #4a5b6e; stroke-width: 0.5; }
.svg-cross { stroke: #a95c22; fill: none; opacity: 0.85; }
.svg-socket { fill: #dfe6ee; stroke: #7c8ea0; stroke-width: 0.4; }
.svg-socket-inner { fill: #fff; stroke: #7c8ea0; stroke-width: 0.3; }
.svg-dia { font-size: 5.5px; text-anchor: middle; fill: #33414f; font-family: inherit; }
.svg-rowlabel { font-size: 5px; text-anchor: end; fill: #a95c22; font-family: inherit; }

footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.6rem 1.4rem;
  color: var(--muted);
  font-size: 0.78rem;
}
