@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;450;500;550;600;650;700&family=Manrope:wght@400;500;600;650;700;750;800&display=swap');
/* The favicon supplies the accent palette; application surfaces stay white. */
:root {
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--surface);
  font-synthesis: none;
  --surface: #ffffff;
  --text: #1d2c43;
  --muted: #62738b;
  --muted-light: #64758d;
  --border: #e4ebf5;
  --brand-blue: #2999ff;
  --brand-purple: #9b6eea;
  --brand-orange: #ffb44b;
  --brand-teal: #38c7b4;
  --accent: #0b70c9;
  --accent-hover: #075eae;
  --accent-text: #1869ad;
  --accent-soft: #edf6ff;
  --accent-border: #b5d7f6;
  --surface-hover: #f3f8ff;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  cursor: default;
}
button,
input {
  font: inherit;
}
button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button {
  color: inherit;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--brand-blue);
  outline-offset: 3px;
}
input:focus {
  outline: none;
  border-color: var(--brand-blue) !important;
  box-shadow: 0 0 0 3px #2999ff35;
}
button svg,
[data-icon] svg {
  display: block;
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-header {
  height: 78px;
  padding: 0 38px;
  display: flex;
  align-items: center;
  gap: 25px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-family: Manrope, sans-serif;
  font-weight: 800;
  font-size: 25px;
  letter-spacing: -1.2px;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-icon {
  width: 33px;
  height: 33px;
  display: flex;
  background: var(--accent-soft);
  border-radius: 8px;
  align-items: center;
  justify-content: center;
}
.brand-icon svg {
  width: 26px;
  height: 26px;
}
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 27px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  transition:
    background 0.16s,
    transform 0.16s;
}
.button:active {
  transform: translateY(1px);
}
.export-button {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 2px #173a5f04;
  padding: 10px 16px;
}
.export-button:hover {
  background: var(--surface-hover);
}
.export-button svg {
  width: 17px;
  height: 17px;
}
.app-main {
  max-width: 1660px;
  margin: 0 auto;
  padding: 36px 38px 0;
}
.workspace {
  display: grid;
  grid-template-columns: 315px minmax(0, 1fr);
  gap: 23px;
  align-items: stretch;
}
.sidebar {
  background: white;
  border: 1px solid var(--border);
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 3px 9px #173a5f02;
}
.input-unit {
  position: relative;
  margin-top: 7px;
}
.input-unit input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 11px 31px 11px 11px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  appearance: textfield;
  min-width: 0;
  transition: border-color 0.15s;
}
.input-unit input::-webkit-inner-spin-button,
.input-unit input::-webkit-outer-spin-button {
  appearance: none;
}
.input-unit > span {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--muted-light);
}
.dimension-times {
  margin-bottom: 13px;
  color: #b3bfd0;
  font-size: 14px;
}
.parts-section {
  padding: 23px 22px 18px;
  border-top: 1px solid var(--border);
}
.text-button {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-text);
  padding: 4px 0;
  white-space: nowrap;
}
.text-button svg {
  width: 13px;
  height: 13px;
}
.parts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 335px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.part-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 10px 9px;
  transition: border-color 0.16s;
  background: var(--surface);
}
.part-card:hover {
  border-color: var(--accent-border);
}
.part-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.part-shape {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--part-bg);
}
.part-shape svg {
  width: 23px;
  height: 23px;
  fill: var(--part-fill);
  stroke: var(--part-stroke);
  stroke-width: 1.4;
}
.part-edit {
  border: 0;
  padding: 0;
  background: none;
  flex: 1;
  min-width: 0;
  text-align: left;
}
.part-name {
  font-size: 12px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  max-width: 154px;
}
.part-dimensions {
  display: block;
  font-size: 10px;
  color: var(--muted-light);
  margin-top: 4px;
}
.icon-button {
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 5px;
  border-radius: 4px;
  color: var(--muted-light);
}
.icon-button:hover {
  background: var(--surface-hover);
  color: var(--accent-text);
}
.icon-button svg {
  width: 14px;
  height: 14px;
}
.part-card .remove-part {
  align-self: flex-start;
  opacity: 0.5;
  padding: 0;
}
.part-card:hover .remove-part {
  opacity: 1;
}
.part-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
  padding-left: 48px;
}
.part-tag {
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--muted-light);
  text-transform: uppercase;
}
.quantity-control {
  display: flex;
  align-items: center;
  height: 25px;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface);
}
.quantity-control button {
  width: 25px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--surface);
  color: var(--muted-light);
}
.quantity-control button:hover {
  background: var(--surface-hover);
}
.quantity-control svg {
  width: 11px;
  height: 11px;
}
.quantity-control input {
  width: 31px;
  padding: 0 2px;
  appearance: textfield;
  text-align: center;
  font-size: 10px;
  border: 0;
  background: transparent;
  outline: none;
}
.quantity-control input::-webkit-inner-spin-button {
  appearance: none;
}
.sidebar-bottom {
  margin-top: auto;
  padding: 0 22px 18px;
}
.optimize-button {
  color: white;
  background: var(--accent);
  border: 1px solid var(--accent);
}
.optimize-button:hover {
  background: var(--accent-hover);
}
.sidebar-bottom .optimize-button {
  width: 100%;
  font-size: 12px;
  padding: 13px 12px;
  gap: 8px;
  box-shadow: 0 3px 5px #173a5f1a;
}
.sidebar-bottom .optimize-button > span:last-child {
  margin-left: auto;
}
.sidebar-bottom .optimize-button svg {
  width: 16px;
  height: 16px;
}
.preview-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 3px 9px #173a5f02;
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 21px 25px;
  border-bottom: 1px solid var(--border);
  height: 78px;
}
.preview-header h2 {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.preview-header p {
  font-size: 10px;
  color: var(--muted-light);
  margin: 6px 0 0;
  letter-spacing: 0.15px;
}
.preview-toolbar {
  display: flex;
  gap: 7px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  padding: 5px 4px;
  box-shadow: 0 1px 2px #173a5f03;
}
.preview-toolbar button {
  background: none;
  border: 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  border-radius: 3px;
}
.preview-toolbar button:hover {
  background: var(--surface-hover);
}
.preview-toolbar svg {
  width: 15px;
  height: 15px;
}
.preview-toolbar > span:not(.toolbar-divider) {
  font-size: 10px;
  color: var(--muted);
  min-width: 34px;
  text-align: center;
}
.toolbar-divider {
  width: 1px;
  height: 15px;
  background: var(--border);
  margin: 0 2px;
}
.canvas-stage {
  flex: 1;
  min-height: 460px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  background-image: radial-gradient(#c6d9f088 0.7px, transparent 0.7px);
  background-size: 16px 16px;
}
#layout-svg {
  width: 100%;
  height: 100%;
  max-height: 610px;
  min-height: 400px;
  display: block;
  overflow: hidden;
  transition: opacity 0.12s;
}
.origin-label {
  position: absolute;
  bottom: 19px;
  left: 23px;
  font-size: 9px;
  color: var(--muted-light);
  display: flex;
  align-items: center;
  gap: 6px;
}
.origin-label > span {
  height: 10px;
  width: 10px;
  border-left: 1px solid #b3bfd0;
  border-bottom: 1px solid #b3bfd0;
}
.layout-summary {
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 23px 25px 25px;
  gap: 20px;
  min-height: 105px;
}
.stat-label {
  display: flex;
  gap: 5px;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 9px;
  white-space: nowrap;
}
.green-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand-teal);
}
.stat-value {
  font-family: Manrope, sans-serif;
  font-size: 24px;
  line-height: 1;
  letter-spacing: -0.6px;
  font-weight: 650;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stat-unit {
  font-size: 16px;
  color: var(--muted);
  font-weight: 500;
}
.area-unit {
  font-size: 13px;
}
.stat-secondary {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted-light);
  letter-spacing: 0;
  margin-left: 1px;
}
.summary-divider {
  height: 39px;
  width: 1px;
  background: #eaf1fa;
}
.mini-meter {
  height: 5px;
  width: 57px;
  border-radius: 4px;
  background: #eaf1fa;
  margin-left: 9px;
  align-self: center;
  overflow: hidden;
}
.mini-meter > span {
  display: block;
  background: var(--brand-teal);
  width: 0;
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s;
}
.overflow-notice {
  background: #fff8ec;
  border-top: 1px solid #f4d6a6;
  padding: 12px 24px;
  font-size: 11px;
  color: #9a5a0a;
  line-height: 1.5;
}
.canvas-empty {
  position: absolute;
  text-align: center;
  padding: 25px;
  max-width: 340px;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: 0 25px 100px #173a5f30;
  padding: 28px;
  width: 470px;
  max-width: calc(100% - 30px);
  color: var(--text);
}
dialog::backdrop {
  background: #14264238;
  backdrop-filter: blur(3px);
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}
.dialog-heading h2 {
  font-family: Manrope, sans-serif;
  font-size: 23px;
  letter-spacing: -0.7px;
  font-weight: 650;
  margin: 9px 0 0;
}
.dialog-heading .icon-button svg {
  width: 18px;
  height: 18px;
}
.shape-picker {
  display: flex;
  gap: 9px;
  margin-bottom: 23px;
}
.shape-picker button {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 6px;
  font-size: 11px;
  color: var(--muted);
}
.shape-picker button svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.5;
}
.shape-picker button.selected {
  background: var(--accent-soft);
  border-color: var(--brand-blue);
  color: var(--accent-text);
}
.dialog-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.dialog-field input {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  width: 100%;
  min-width: 0;
}
.dialog-dimensions {
  display: flex;
  gap: 12px;
  margin-top: 17px;
}
.dialog-dimensions > label {
  flex: 1;
  min-width: 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 27px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.dialog-actions .button {
  font-size: 12px;
}
.secondary-button {
  background: white;
  border-color: var(--border);
  color: var(--muted);
}
.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translate(-50%, 15px);
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--accent-text);
  padding: 13px 20px;
  font-size: 12px;
  box-shadow: 0 7px 30px #173a5f15;
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.2s,
    opacity 0.2s;
  max-width: calc(100% - 36px);
  z-index: 10;
  line-height: 1.5;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
[hidden] {
  display: none !important;
}
.part-path {
  transition: fill-opacity 0.15s;
}
.part-path:hover {
  fill-opacity: 0.8;
}
.input-invalid {
  border-color: #bf7b1e !important;
}
.busy svg {
  animation: turn 1s linear infinite;
}
@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}
@media (min-width: 1550px) {
  .canvas-stage {
    min-height: 560px;
  }
  .parts-list {
    max-height: 420px;
  }
  .app-main {
    padding-top: 43px;
  }
}
@media (max-width: 1150px) {
  .app-header {
    padding: 0 24px;
  }
  .app-main {
    padding: 29px 24px 0;
  }
  .workspace {
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 18px;
  }
  .parts-section {
    padding-left: 18px;
    padding-right: 18px;
  }
  .sidebar-bottom {
    padding-left: 18px;
    padding-right: 18px;
  }
  .layout-summary {
    gap: 14px;
    padding: 21px 18px;
  }
  .mini-meter {
    width: 40px;
  }
  .canvas-stage {
    min-height: 460px;
  }
  .preview-header {
    padding-left: 20px;
    padding-right: 20px;
  }
}
@media (max-width: 850px) {
  .app-main {
    padding: 26px 18px 0;
  }
  .app-header {
    padding: 0 20px;
    height: 68px;
    gap: 18px;
  }
  .brand {
    font-size: 23px;
  }
  .workspace {
    grid-template-columns: 265px minmax(0, 1fr);
    gap: 15px;
  }
  .parts-section {
    padding: 19px 15px;
  }
  .sidebar-bottom {
    padding-left: 15px;
    padding-right: 15px;
  }
  .text-button {
    font-size: 9px;
  }
  .parts-list {
    max-height: 340px;
  }
  .layout-summary {
    gap: 10px;
    padding: 21px 15px;
  }
  .stat-value {
    font-size: 20px;
  }
  .stat-label {
    font-size: 8px;
  }
  .mini-meter {
    display: none;
  }
  .stat-unit {
    font-size: 13px;
  }
  .preview-header {
    padding: 18px 15px;
  }
  .canvas-stage {
    min-height: 420px;
  }
  .origin-label {
    left: 15px;
  }
  .preview-toolbar {
    gap: 3px;
  }
  .preview-toolbar button {
    padding: 2px;
  }
}
@media (max-width: 650px) {
  .header-actions {
    gap: 0;
  }
  .app-header {
    padding: 0 18px;
  }
  .export-button {
    font-size: 11px;
    padding: 9px 11px;
  }
  .app-main {
    padding-top: 25px;
  }
  .workspace {
    display: flex;
    flex-direction: column;
    gap: 17px;
  }
  .sidebar {
    display: grid;
    grid-template-columns: 1fr;
  }
  .parts-section {
    padding: 20px;
  }
  .text-button {
    font-size: 11px;
  }
  .parts-list {
    max-height: 310px;
  }
  .part-name {
    max-width: 220px;
  }
  .part-bottom {
    margin-top: 4px;
  }
  .part-card {
    padding: 10px 12px;
  }
  .sidebar-bottom {
    padding: 0 20px 17px;
  }
  .sidebar-bottom .optimize-button {
    padding: 13px;
    font-size: 13px;
  }
  .preview-header {
    height: 72px;
    padding: 17px 18px;
  }
  .canvas-stage {
    min-height: 340px;
    height: 340px;
    flex: auto;
  }
  #layout-svg {
    min-height: 300px;
    height: 100%;
    max-height: none;
  }
  .layout-summary {
    padding: 21px 19px;
    gap: 14px;
    min-height: 95px;
  }
  .stat-label {
    font-size: 9px;
  }
  .stat-value {
    font-size: 24px;
  }
  .stat-unit {
    font-size: 14px;
  }
  dialog {
    padding: 23px;
  }
  .dialog-dimensions {
    gap: 10px;
  }
  .dialog-actions .button {
    padding: 10px 13px;
  }

  .part-dimensions {
    font-size: 10px;
  }
}
@media (min-width: 651px) {
  .app-main {
    padding-top: 28px;
  }
  .parts-section {
    padding-top: 19px;
    padding-bottom: 17px;
  }
  .part-card {
    padding-top: 9px;
    padding-bottom: 8px;
  }
  .part-shape {
    width: 33px;
    height: 33px;
  }
  .part-shape svg {
    width: 21px;
    height: 21px;
  }
  .part-bottom {
    padding-left: 43px;
    margin-top: 4px;
  }
  .quantity-control {
    height: 22px;
  }
  .parts-list {
    gap: 8px;
  }
  .sidebar-bottom {
    padding-bottom: 17px;
  }
  .sidebar-bottom .optimize-button {
    padding: 12px;
  }
  .canvas-stage {
    min-height: 420px;
  }
}
@media (min-width: 651px) and (max-height: 800px) {
  .app-header {
    height: 65px;
  }
  .app-main {
    padding-top: 21px;
  }
  .input-unit input {
    padding-top: 9px;
    padding-bottom: 9px;
  }
  .parts-section {
    padding-top: 17px;
    padding-bottom: 15px;
  }
  .part-card {
    position: relative;
    padding: 11px 10px;
  }
  .part-main {
    min-height: 35px;
  }
  .part-edit {
    padding-right: 30px;
  }
  .part-name {
    font-size: 11px;
  }
  .part-dimensions {
    font-size: 9px;
  }
  .part-bottom {
    position: absolute;
    bottom: 12px;
    right: 10px;
    padding: 0;
    margin: 0;
  }
  .part-tag {
    display: none;
  }
  .part-card .remove-part {
    position: absolute;
    top: 8px;
    right: 9px;
  }
  .quantity-control {
    height: 22px;
  }
  .quantity-control button {
    width: 19px;
  }
  .quantity-control input {
    width: 25px;
  }
  .part-shape {
    width: 31px;
    height: 31px;
  }
  .part-dimensions {
    max-width: 110px;
    overflow: hidden;
  }
  .sidebar-bottom {
    padding-bottom: 13px;
  }
  .canvas-stage {
    min-height: 355px;
  }
  .preview-header {
    height: 68px;
  }
  .layout-summary {
    min-height: 91px;
    padding-top: 19px;
    padding-bottom: 19px;
  }
  .stat-value {
    font-size: 22px;
  }
}
@media (min-width: 651px) {
  .workspace {
    height: calc(100vh - 260px);
    min-height: 610px;
  }
  .preview-header {
    flex-shrink: 0;
  }
  .canvas-stage {
    min-height: 0;
  }
  #layout-svg {
    position: absolute;
    inset: 0;
    min-height: 0;
    max-height: none;
    width: 100%;
    height: 100%;
  }
  .layout-summary {
    flex-shrink: 0;
  }
  .parts-section {
    min-height: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 16px;
    padding-bottom: 14px;
  }
  .parts-list {
    min-height: 0;
    max-height: none;
    flex: 1;
  }
  .sidebar-bottom {
    flex-shrink: 0;
  }
  .part-card {
    position: relative;
    flex-shrink: 0;
    padding: 11px 10px;
  }
  .part-main {
    min-height: 35px;
  }
  .part-edit {
    padding-right: 40px;
  }
  .part-name {
    font-size: 11px;
  }
  .part-dimensions {
    font-size: 9px;
  }
  .part-bottom {
    position: absolute;
    bottom: 12px;
    right: 10px;
    padding: 0;
    margin: 0;
  }
  .part-tag {
    display: none;
  }
  .part-card .remove-part {
    position: absolute;
    top: 8px;
    right: 9px;
  }
  .quantity-control {
    height: 22px;
  }
  .quantity-control button {
    width: 19px;
  }
  .quantity-control input {
    width: 25px;
  }
  .part-shape {
    width: 31px;
    height: 31px;
  }
  .part-dimensions {
    max-width: 110px;
    overflow: hidden;
  }
}
@media (min-width: 651px) and (max-height: 800px) {
  .workspace {
    height: calc(100vh - 200px);
    min-height: 550px;
  }
}
.part-path {
  cursor: grab;
  touch-action: none;
  outline: none;
}
.part-path.placement-selected > path,
.part-path.placement-selected > circle,
.part-path:focus-visible > path,
.part-path:focus-visible > circle {
  stroke: var(--accent);
  stroke-width: 2.3;
  vector-effect: non-scaling-stroke;
}
.part-path.placement-invalid > path,
.part-path.placement-invalid > circle {
  stroke: #bf7b1e;
  stroke-width: 2;
  stroke-dasharray: 5 3;
  vector-effect: non-scaling-stroke;
}
.part-path.drag-invalid > path,
.part-path.drag-invalid > circle {
  fill: #ffe8c2;
  fill-opacity: 0.75;
}
.is-dragging,
.is-dragging .part-path {
  cursor: grabbing;
}
.drag-position {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent-text);
  box-shadow: 0 3px 12px #173a5f0a;
  pointer-events: none;
  white-space: nowrap;
}
.drag-position.invalid {
  color: #9a5a0a;
  border-color: #f4d6a6;
  background: #fff8ec;
}

.app-header {
  height: 64px;
  padding: 0 24px;
}
.app-main {
  max-width: none;
  padding: 18px 24px 24px;
}
.dialog-heading h2 {
  margin-top: 0;
}
@media (min-width: 651px) {
  .workspace {
    height: calc(100dvh - 106px);
    min-height: 550px;
  }
}
@media (max-width: 650px) {
  .app-header {
    padding: 0 16px;
  }
  .app-main {
    padding: 16px 16px 20px;
  }
}

.parts-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 14px;
}
.parts-actions .button {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  gap: 6px;
  font-size: 11px;
  white-space: nowrap;
}
.parts-actions svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.add-shape-button {
  background: var(--accent);
  color: var(--surface);
}
.add-shape-button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.add-shape-button:hover {
  background: var(--accent-hover);
}
.parts-actions .secondary-button {
  color: var(--accent-text);
  background: var(--surface);
  border-color: var(--border);
}
.parts-actions .secondary-button:hover {
  background: var(--surface-hover);
  border-color: var(--accent-border);
}
.parts-section.is-empty {
  justify-content: center;
  min-height: 220px;
}
.parts-section.is-empty .parts-actions,
.canvas-empty .parts-actions {
  flex-direction: column;
  align-self: center;
  width: 100%;
  max-width: 220px;
  margin: 0;
  gap: 10px;
}
.parts-section.is-empty .parts-actions .button,
.canvas-empty .parts-actions .button {
  flex: auto;
  width: 220px;
  max-width: 100%;
  padding: 12px 14px;
  font-size: 12px;
  gap: 6px;
}
.parts-section.is-empty .parts-list {
  display: none;
}

.header-actions {
  gap: 8px;
}
.config-button {
  border-color: var(--border);
  background: var(--surface);
  font-size: 12px;
  padding: 10px 12px;
}
.config-button:hover {
  background: var(--surface-hover);
}
.config-button svg {
  width: 16px;
  height: 16px;
}
@media (max-width: 650px) {
  .app-header {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .header-actions {
    width: 100%;
    margin-left: 0;
    gap: 7px;
  }
  .header-actions .button {
    flex: 1;
    font-size: 11px;
    padding: 9px 8px;
    gap: 6px;
  }
}
.sketch-toolbar {
  flex-wrap: wrap;
}
.dialog-actions {
  flex-wrap: wrap;
}

dialog {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.shape-picker button {
  min-width: 0;
}
.sketch-editor {
  margin-top: 18px;
}
.sketch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.sketch-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sketch-toolbar button {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  padding: 6px 8px;
  font-size: 10px;
  color: var(--muted);
}
.sketch-toolbar button:hover {
  background: var(--surface-hover);
}
.sketch-toolbar svg {
  width: 13px;
  height: 13px;
}
#sketch-svg {
  width: 100%;
  height: 240px;
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
.sketch-details {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.sketch-details p {
  margin: 0;
  font-size: 10px;
  line-height: 1.6;
  color: var(--muted);
}
.sketch-error {
  font-size: 11px;
  color: #9a5a0a;
  line-height: 1.5;
  margin: 10px 0 0;
}
.sketch-handle {
  cursor: grab;
}
.sketch-handle:active {
  cursor: grabbing;
}
.sketch-edge-hit,
[data-sketch-contour] {
  cursor: pointer;
}
@media (max-width: 650px) {
  #sketch-svg {
    height: 210px;
  }
  .shape-picker {
    gap: 7px;
  }
  .shape-picker button {
    font-size: 10px;
    padding: 13px 5px;
  }
  .sketch-toolbar button {
    padding: 6px;
    font-size: 10px;
  }
  .sketch-actions {
    gap: 3px;
  }
  .sketch-details p {
    font-size: 9px;
  }
}

/* Plate tabs and editable settings stay with the canvas. */
.brand-icon {
  width: 36px;
  height: 36px;
  background: none;
  border-radius: 10px;
}
.language-switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  margin-left: 8px;
  min-width: 112px;
  height: 36px;
  padding: 7px 32px 7px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2362738b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 11px center;
  color: var(--accent-text);
  font:
    500 12px/1.2 'DM Sans',
    sans-serif;
  cursor: pointer;
  transition:
    border-color 0.12s,
    background-color 0.12s;
}
.language-switch:hover {
  border-color: var(--accent-border);
  background-color: var(--surface);
}
.language-switch:focus-visible {
  outline: 3px solid var(--brand-blue);
  outline-offset: 3px;
}
.language-switch option {
  background: var(--surface);
  color: var(--text);
}
.plate-tab-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.plate-tabs {
  display: flex;
  align-items: stretch;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 1;
  min-width: 0;
}
.plate-tab {
  border: 1px solid transparent;
  border-bottom: 0;
  background: transparent;
  border-radius: 7px 7px 0 0;
  padding: 10px 14px 12px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  display: flex;
  gap: 8px;
  align-items: center;
}
.plate-tab[aria-selected='true'] {
  background: var(--accent-soft);
  border-color: var(--border);
  color: var(--accent-text);
  box-shadow: inset 0 -2px var(--brand-blue);
}
.plate-tab-bar > .text-button {
  padding: 9px 0 14px;
  font-size: 11px;
}
.preview-header {
  height: auto;
  min-height: 96px;
  gap: 18px;
  padding: 15px 20px;
  flex-wrap: wrap;
}
.plate-dimensions {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex: 1;
  min-width: 0;
}
.plate-dimensions > label {
  font-size: 10px;
  color: var(--muted);
  min-width: 0;
  flex: 1;
  max-width: 145px;
}
.plate-dimensions .input-unit {
  margin-top: 5px;
}
.plate-dimensions .input-unit input {
  font-size: 13px;
  padding: 9px 28px 9px 10px;
}
.plate-dimensions .dimension-times {
  margin-bottom: 11px;
}
.preview-toolbar {
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 2px;
}
.preview-toolbar #delete-plate {
  color: var(--muted-light);
}
.parts-section {
  border-top: 0;
}
.layout-summary {
  justify-content: space-around;
}
.summary-divider {
  flex-shrink: 0;
}
.part-name {
  max-width: 100%;
  padding-right: 6px;
}
@media (min-width: 651px) and (max-width: 1080px) {
  .preview-header {
    gap: 10px;
  }
  .plate-dimensions {
    flex-basis: 100%;
  }
  .preview-toolbar {
    margin-left: auto;
  }
  .plate-dimensions > label {
    max-width: none;
  }
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}
@media (max-width: 650px) {
  .language-switch {
    margin-left: auto;
  }
  .plate-tab-bar {
    padding: 10px 13px 0;
    gap: 10px;
  }
  .plate-tab {
    padding: 10px;
    font-size: 11px;
  }
  .preview-header {
    height: auto;
    min-height: 0;
    padding: 13px;
    gap: 12px;
  }
  .plate-dimensions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    flex-basis: 100%;
  }
  .plate-dimensions > label {
    max-width: none;
    font-size: 11px;
  }
  .plate-dimensions .dimension-times {
    display: none;
  }
  .preview-toolbar {
    margin-left: auto;
  }
  .plate-tab-bar > .text-button {
    font-size: 10px;
  }
  .parts-list {
    max-height: 280px;
  }
  .stat-label {
    white-space: normal;
    line-height: 1.4;
  }
}
.confirm-message {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}
.danger-button {
  background: #9a5a0a;
  border-color: #9a5a0a;
  color: var(--surface);
}
.danger-button:hover {
  background: #7e4704;
}
.sketch-inline-length {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  height: 26px;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: default;
}
.sketch-inline-length input {
  font: inherit;
  color: inherit;
  text-align: right;
  width: 76px;
  min-width: 0;
  height: 24px;
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: #ffffffdd;
  outline: none;
}
.sketch-inline-length input:hover {
  border-color: var(--accent-border);
  background: var(--surface);
}
.sketch-inline-length input:focus {
  border-color: var(--brand-blue);
  background: var(--surface);
}
.sketch-inline-length span {
  pointer-events: none;
}
.sketch-actions button {
  border-color: var(--border);
  background: var(--surface);
  color: var(--accent-text);
  font-weight: 550;
  padding: 7px 9px;
  gap: 6px;
}
.sketch-actions button:hover:enabled {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.sketch-actions button:disabled {
  opacity: 0.65;
  background: var(--surface);
}
.sketch-actions svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
#delete-plate-dialog {
  width: 520px;
}
#layout-svg.can-pan {
  cursor: grab;
  touch-action: none;
}
#layout-svg.space-pan .part-path {
  cursor: grab;
}
#layout-svg.is-panning,
#layout-svg.is-panning .part-path {
  cursor: grabbing;
}
.origin-label {
  pointer-events: none;
}

.holes-editor {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.hole-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.hole-add-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}
.hole-add-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 38px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  transition:
    background 0.12s,
    border-color 0.12s;
}
.hole-add-actions svg {
  width: auto;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  flex-shrink: 0;
}
.holes-editor > .text-button {
  margin: 8px 0;
}
#hole-preview {
  width: 100%;
  height: 210px;
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  touch-action: none;
}
#hole-preview [data-hole-id] {
  cursor: grab;
}
#hole-preview [data-hole-id]:active {
  cursor: grabbing;
}

/* Dimension labels stay readable and editable in drawing coordinates. */

.hole-add-actions button:hover:enabled {
  border-color: var(--brand-blue);
  background: var(--accent-soft);
}
.hole-add-actions button:active:enabled {
  background: #dceeff;
}
.hole-add-actions button:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 1px;
}
#hole-preview {
  height: clamp(290px, calc(100dvh - 370px), 500px);
  background: var(--surface);
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
#hole-preview:focus {
  outline: none;
}
#hole-preview:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}
.hole-dimension-lines,
.hole-dimension-leader,
.hole-centre-guides {
  fill: none;
  pointer-events: none;
}
.hole-dimension-line {
  stroke: #8ab7de;
  stroke-width: 0.8;
}
.hole-dimension-extension,
.hole-dimension-leader {
  stroke: #8ab7de;
  stroke-width: 0.7;
}
.hole-dimension-leader {
  opacity: 0.55;
}
.hole-centre-guides {
  stroke: #b6cce5;
  stroke-dasharray: 7 4 1 4;
  stroke-width: 0.7;
  opacity: 0.25;
}
.hole-dimension-value {
  cursor: pointer;
  outline: none;
}
.hole-dimension-value rect {
  fill: var(--surface);
  fill-opacity: 0.88;
  stroke: transparent;
  stroke-width: 1;
}
.hole-dimension-value text {
  fill: var(--accent-text);
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.hole-dimension-value:hover rect,
.hole-dimension-value:focus-visible rect {
  fill: var(--surface);
  stroke: var(--brand-blue);
  stroke-width: 1.5;
}
.hole-dimension-input {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 30px;
  padding: 0 4px;
  border: 1.5px solid var(--brand-blue);
  border-radius: 4px;
  background: var(--surface);
  color: var(--accent);
  font:
    600 12px 'DM Sans',
    sans-serif;
  white-space: nowrap;
}
.hole-dimension-input input {
  padding: 3px 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  flex: 1;
  width: 0;
  min-width: 0;
  text-align: right;
  box-shadow: none !important;
}
.hole-dimension-input.is-invalid {
  border-color: #bf7b1e;
}
.hole-dimension-input span {
  pointer-events: none;
}
.hole-dimension-legend {
  font-size: 10px;
  fill: var(--muted);
  pointer-events: none;
}
@media (max-width: 650px) {
  #hole-preview {
    height: 340px;
  }
}

#hole-workspace {
  margin-top: 10px;
}
.hole-item {
  outline: none;
}
.hole-hover-bridge,
.sketch-point-hover-bridge {
  fill: none;
  stroke: transparent;
  stroke-width: 26;
  pointer-events: stroke;
}
.hole-delete,
.sketch-point-delete {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: visible;
}
.hole-item:hover .hole-delete,
.hole-item:focus-within .hole-delete,
#hole-preview:focus-visible .hole-item.is-selected .hole-delete {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.hole-delete button,
.sketch-point-delete button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 5px;
  border: 1px solid #f4d6a6;
  border-radius: 50%;
  background: var(--surface);
  color: #9a5a0a;
  box-shadow: 0 2px 5px #173a5f12;
  cursor: pointer;
}
.hole-delete button:hover,
.sketch-point-delete button:hover {
  background: #fff8ec;
  border-color: #bf7b1e;
}
.hole-delete button svg,
.sketch-point-delete button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}
.hole-item:focus-visible > g > path:first-child {
  stroke: var(--accent);
  stroke-width: 2.5;
}
.hole-alignment-guides {
  fill: none;
  stroke: var(--brand-purple);
  stroke-width: 1.2;
}
.hole-alignment-guides path {
  stroke-dasharray: 5 4;
}
.hole-alignment-guides circle {
  fill: var(--surface);
  stroke-width: 1.5;
}
.hole-alignment-guides .hole-alignment-centre {
  fill: var(--brand-purple);
  stroke: var(--surface);
  stroke-width: 1;
}
.hole-measurement.level-spacing {
  opacity: 0.8;
}
.hole-measurement.level-spacing .hole-dimension-extension {
  stroke-dasharray: 3 3;
}
.hole-dimension-value.level-spacing rect {
  fill: #f6f1fe;
  fill-opacity: 0.95;
}
.hole-dimension-value.level-spacing .dimension-number,
.hole-dimension-value.level-spacing .dimension-prefix {
  fill: #7452a7;
}
.hole-item.is-spacing-reference > g > path:first-child {
  stroke: var(--brand-purple);
  stroke-width: 2;
}
@media (hover: none) {
  .hole-item.is-selected .hole-delete {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

.hole-dimension-value.is-clearance rect {
  fill: var(--accent-soft);
  stroke: transparent;
  fill-opacity: 0.9;
}
.hole-clearance-line {
  stroke: #8ab7de;
  stroke-width: 0.9;
}

/* Keep the active hole readable while the rest of the drawing recedes. */
.dimension-prefix {
  font-size: 10.5px;
  font-weight: 450;
  fill: var(--muted);
}
.dimension-number {
  font-size: 12px;
  font-weight: 600;
}
.dimension-unit {
  font-size: 9px;
  font-weight: 400;
  fill: var(--muted);
}
.level-primary .dimension-number {
  font-size: 13px;
  font-weight: 650;
}
.level-primary .dimension-prefix {
  font-size: 11.5px;
}
.hole-dimension-value.level-context rect,
.hole-dimension-value.level-coordinate rect {
  fill: var(--surface);
  fill-opacity: 0.96;
}
.hole-dimension-value.level-context text,
.hole-dimension-value.level-coordinate text,
.hole-dimension-value.level-quiet text {
  fill: var(--muted);
}
.level-context .dimension-number,
.level-coordinate .dimension-number,
.level-quiet .dimension-number {
  font-size: 10.5px;
  font-weight: 450;
  fill: var(--muted);
}
.level-context .dimension-prefix,
.level-coordinate .dimension-prefix,
.level-quiet .dimension-prefix {
  font-size: 10px;
  fill: var(--muted);
}
.level-context .dimension-unit,
.level-coordinate .dimension-unit,
.level-quiet .dimension-unit {
  font-size: 8.5px;
}
.hole-dimension-value.level-quiet rect {
  fill-opacity: 0.55;
}
.hole-dimension-leader.level-quiet {
  opacity: 0.3;
}
.hole-measurement {
  opacity: 0.65;
}
.hole-measurement.level-context,
.hole-measurement.level-coordinate {
  opacity: 0.4;
}
.hole-measurement.level-coordinate .hole-dimension-extension {
  stroke-dasharray: 3 4;
}
.hole-measurement.is-emphasized {
  opacity: 1;
}
.hole-measurement.is-emphasized .hole-dimension-line,
.hole-measurement.is-emphasized .hole-dimension-extension {
  stroke: var(--accent);
  stroke-width: 1.3;
}
.hole-dimension-leader.is-emphasized {
  opacity: 1;
  stroke: var(--accent);
  stroke-width: 1.1;
}
.hole-dimension-value.is-emphasized rect {
  fill: var(--surface);
  fill-opacity: 1;
  stroke: var(--accent-border);
}
.hole-dimension-value.is-emphasized text,
.hole-dimension-value.is-emphasized .dimension-number {
  fill: var(--accent);
}
.hole-dimension-input > span {
  font-size: 10.5px;
  font-weight: 450;
  color: var(--muted);
}
.hole-dimension-input > span:last-child {
  font-size: 9px;
}

/* Shape selection is a separate first step; dimensions and holes share the next. */
.part-details {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
#part-dialog .dialog-heading {
  align-items: center;
}
.part-wizard-nav {
  margin: 0;
}
.part-wizard-nav .text-button {
  padding: 4px 0;
  font-size: 12px;
  gap: 6px;
}
.part-wizard-nav svg {
  width: 15px;
  height: 15px;
}
dialog.is-choosing-shape {
  width: 480px;
  padding: 26px;
}
.is-choosing-shape .dialog-heading {
  margin-bottom: 22px;
}
.is-choosing-shape .shape-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}
.is-choosing-shape .shape-picker button {
  flex-direction: column;
  gap: 12px;
  padding: 28px 12px;
  font-size: 13px;
}
.is-choosing-shape .shape-picker button svg {
  width: 32px;
  height: 32px;
}
.is-choosing-shape .shape-picker button:hover {
  background: var(--accent-soft);
  border-color: var(--brand-blue);
  color: var(--accent-text);
}
@media (max-width: 650px) {
  dialog.is-choosing-shape {
    padding: 22px 18px;
  }
  .is-choosing-shape .shape-picker {
    gap: 10px;
  }
  .is-choosing-shape .shape-picker button {
    padding: 23px 8px;
    font-size: 12px;
  }
  .is-choosing-shape .dialog-heading h2 {
    font-size: 20px;
  }
}

/* Keep one editing workspace, viewport, and footer when switching tools. */
#part-dialog:not(.is-choosing-shape) {
  width: 960px;
  height: min(800px, calc(100dvh - 32px));
  padding: 20px;
  overflow: hidden;
}
#part-dialog:not(.is-choosing-shape) #part-form {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#part-dialog:not(.is-choosing-shape) .dialog-heading {
  flex-shrink: 0;
  height: 28px;
  margin: 0 0 12px;
}
#part-dialog:not(.is-choosing-shape) .part-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 40px minmax(0, 1fr) auto;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
#part-dialog .part-details > .dialog-field {
  grid-column: 1;
  min-width: 0;
}
#part-dialog #part-name {
  height: 40px;
}
.shape-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 38px minmax(220px, 1fr) 80px;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
#part-dialog .holes-editor,
#part-dialog .sketch-editor {
  display: contents;
}
#part-dialog .hole-toolbar {
  grid-row: 1;
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
}

#part-dialog .hole-add-actions {
  flex-wrap: nowrap;
  gap: 8px;
  flex-shrink: 0;
}
#part-dialog .hole-add-actions button {
  height: 34px;
  width: 46px;
}
#part-dialog #hole-workspace,
#part-dialog #sketch-svg {
  grid-row: 2;
  grid-column: 1;
  margin: 0;
  min-height: 0;
  height: 100%;
}
#part-dialog #hole-preview {
  height: 100%;
  min-height: 220px;
  width: 100%;
}
#part-dialog #sketch-svg {
  width: 100%;
  min-height: 220px;
}
#part-dialog #hole-preview,
#part-dialog #sketch-svg {
  border-color: var(--border);
  border-radius: 8px;
  background-color: var(--surface);
}
.sketch-controls {
  grid-row: 3;
  grid-column: 1;
  display: grid;
  grid-template-rows: 34px 30px;
  gap: 8px;
  min-width: 0;
}
#part-dialog .sketch-toolbar {
  margin: 0;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
#part-dialog .sketch-actions {
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 5px;
}
#part-dialog .sketch-toolbar button {
  padding: 7px 9px;
  font-size: 11px;
  white-space: nowrap;
}
#part-dialog #sketch-dxf {
  height: 34px;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 500;
  transition:
    background 0.15s,
    border-color 0.15s;
}
#part-dialog #sketch-dxf:hover {
  background: var(--surface-hover);
  border-color: var(--accent-border);
}
#part-dialog #sketch-dxf svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.sketch-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
#part-dialog .sketch-details {
  margin: 0;
  gap: 10px;
  min-width: 0;
  align-items: center;
  flex: 1;
}
#part-dialog .sketch-details p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#part-dialog .dialog-dimensions {
  display: none;
}
#part-dialog #sketch-error {
  grid-row: 5;
  grid-column: 1;
  margin: 0;
  line-height: 1.5;
}
#part-dialog #hole-error {
  grid-row: 4;
  grid-column: 1;
  margin: 0;
  line-height: 1.5;
}
#part-dialog:not(.is-choosing-shape) .dialog-actions {
  grid-column: 1;
  margin: 0;
  padding-top: 14px;
  min-height: 55px;
  align-items: center;
  flex-wrap: nowrap;
}
#part-dialog .dialog-actions .button {
  min-height: 40px;
}
@media (max-width: 650px) {
  #part-dialog:not(.is-choosing-shape) {
    padding: 14px;
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
    max-width: calc(100% - 20px);
  }
  #part-dialog:not(.is-choosing-shape) .part-details {
    gap: 10px;
  }
  #part-dialog .hole-toolbar {
    gap: 6px;
  }

  #part-dialog .hole-add-actions {
    gap: 5px;
  }
  #part-dialog .hole-add-actions button {
    width: 36px;
    height: 32px;
  }
  #part-dialog .hole-add-actions svg {
    height: 21px;
  }
  #part-dialog .sketch-toolbar {
    gap: 8px;
  }
  #part-dialog .sketch-toolbar button {
    padding: 6px;
    font-size: 10px;
  }
  #part-dialog .dialog-actions {
    gap: 8px;
  }
  #part-dialog .dialog-actions .button {
    font-size: 11px;
    padding: 9px 10px;
    gap: 6px;
  }
  #part-dialog .sketch-details p {
    white-space: normal;
  }
  #part-dialog .sketch-footer {
    gap: 8px;
  }
  #part-dialog .sketch-details {
    justify-content: flex-start;
  }
}

#part-dialog #sketch-svg:focus {
  outline: none;
}
#part-dialog #sketch-svg:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

@media (max-width: 650px) {
  #part-dialog .shape-workspace {
    grid-template-rows: 34px minmax(220px, 1fr) 116px;
  }
  #part-dialog .sketch-controls {
    grid-template-rows: 72px 32px;
  }
  #part-dialog .sketch-toolbar {
    flex-wrap: wrap;
    align-content: flex-start;
    overflow: visible;
    gap: 7px;
  }
  #part-dialog .sketch-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
body:has(dialog[open]) {
  overflow: hidden;
}

/* One drawing: outline handles below interactive hole and dimension annotations. */
#part-dialog .hole-toolbar {
  justify-content: space-between;
}
#part-dialog #hole-workspace {
  z-index: 1;
  pointer-events: none;
}
#part-dialog #hole-preview {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}
#part-dialog #hole-preview .hole-item,
#part-dialog #hole-preview .hole-dimension-value,
#part-dialog #hole-preview [data-dimension-editor],
#part-dialog #hole-preview .hole-delete {
  pointer-events: auto;
}
#part-dialog #hole-preview:focus-visible {
  outline: none;
}

.sketch-point:hover .sketch-point-delete,
.sketch-point:focus-within .sketch-point-delete,
#sketch-svg:focus-visible .sketch-point.is-selected .sketch-point-delete {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.sketch-point.is-dragging .sketch-point-delete {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.sketch-point-delete button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
@media (hover: none) {
  .sketch-point.is-selected .sketch-point-delete {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .sketch-point.is-dragging .sketch-point-delete {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

/* Edge measurements remain visible; the active value opens an inline editor. */
.sketch-edge-value {
  cursor: pointer;
  outline: none;
}
.sketch-edge-value rect {
  fill: var(--surface);
  fill-opacity: 0.92;
  stroke: transparent;
}
.sketch-edge-value text {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  fill: var(--accent-text);
  pointer-events: none;
}
.sketch-edge-value .sketch-edge-unit {
  font-size: 9px;
  font-weight: 400;
  fill: var(--muted);
}
.sketch-edge-value:hover rect,
.sketch-edge-value:focus-visible rect {
  fill: var(--surface);
  stroke: var(--accent-border);
}

#part-dialog .sketch-actions button {
  width: 34px;
  height: 34px;
  justify-content: center;
  padding: 8px;
  gap: 0;
  flex-shrink: 0;
}

.annotation-toggles {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.annotation-toggles button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.annotation-toggles button[aria-pressed='true'] {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.annotation-toggles button:hover {
  border-color: var(--brand-blue);
  background: var(--surface-hover);
  color: var(--accent-text);
}
.annotation-toggles button svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.5;
}

#plate-settings-dialog {
  width: 520px;
}
.plate-settings-values {
  display: grid;
  gap: 10px;
  margin: 20px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}
.plate-settings-values > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
}
.plate-settings-values dt {
  color: var(--muted);
}
.plate-settings-values dd {
  margin: 0;
  color: var(--accent-text);
  font-weight: 600;
  white-space: nowrap;
}

/* Copyright fits in the existing bottom padding without resizing the workspace. */
.app-main {
  position: relative;
}
.app-footer {
  position: absolute;
  right: 16px;
  bottom: 4px;
  left: 16px;
  color: var(--muted);
  font-size: 10px;
  line-height: 14px;
  text-align: center;
}

.app-footer a,
.app-footer .email-copy {
  margin-left: 12px;
  color: inherit;
  text-decoration: none;
}
.app-footer a:hover {
  text-decoration: underline;
}

/* Legal links wrap below the workspace on narrow screens. */
@media (max-width: 650px) {
  .app-footer {
    position: static;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 12px;
    margin-top: 14px;
  }
  .app-footer a,
  .app-footer .email-copy {
    margin-left: 0;
  }
}

.email-copy {
  position: relative;
  display: inline-block;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: baseline;
}
.email-copy-feedback {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: 0 2px 8px #173a5f12;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  opacity: 0;
  transform: translateX(-50%);
  pointer-events: none;
}
.email-copy[data-copy-state] .email-copy-feedback {
  opacity: 1;
}
.email-copy[data-copy-state='copied'] .email-copy-feedback::before {
  content: '✓';
}
.email-copy[data-copy-state='error'] .email-copy-feedback {
  color: #9a5a0a;
}
