.mp-viewer {
  --mp-ink: var(--navy, #0d2347);
  --mp-muted: var(--text-secondary, #46566e);
  --mp-accent: var(--accent, #c08a2e);
  --mp-glass: rgba(249, 252, 255, .92);
  position: relative;
  min-width: 0;
  min-height: 190px;
  color: var(--mp-ink);
  font-family: var(--body, system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.45;
}
.mp-viewer *, .mp-viewer *::before { box-sizing: border-box; }
.mp-viewer [hidden], .mp-viewer .mp-hidden { display: none !important; }
.mp-viewer button, .mp-viewer select, .mp-viewer input, .mp-action {
  max-width: 100%;
  min-height: 44px;
  border: 1px solid #b9c8d6;
  border-radius: 9px;
  padding: 7px 11px;
  color: inherit;
  background: #f9fcff;
  font: inherit;
}
.mp-viewer button, .mp-viewer select, .mp-action { cursor: pointer; }
.mp-viewer button:disabled { cursor: default; opacity: .48; }
.mp-viewer button[aria-pressed="true"], .mp-viewer button:hover:not(:disabled) { background: #dceaf7; }
.mp-viewer :focus-visible { outline: 3px solid var(--mp-accent); outline-offset: 2px; }
.mp-toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: end;
  padding: 12px;
  border: 1px solid #c8d5e1;
  border-radius: 17px 17px 0 0;
  background: var(--mp-glass);
  backdrop-filter: blur(14px);
}
.mp-toolbar label, .mp-work label { display: grid; gap: 3px; font-weight: 600; }
.mp-toolbar label { min-width: 0; }
.mp-toolbar select { width: 100%; }
.mp-stage {
  position: relative;
  isolation: isolate;
  height: clamp(420px, 67vh, 690px);
  overflow: hidden;
  background: #e3ebf2;
  border: 1px solid #c8d5e1;
  border-top: 0;
  border-radius: 0 0 17px 17px;
}
.mp-surface, .mp-surface canvas, .mp-drawing, .mp-labels { position: absolute; inset: 0; width: 100%; height: 100%; }
.mp-surface canvas { cursor: grab; }
.mp-surface canvas:active { cursor: grabbing; }
.mp-over-lot canvas { cursor: pointer; }
.mp-drawing { max-width: none; }
.mp-sheet-open .mp-map { width: calc(100% - min(324px, 46%)); }
.mp-overlay, .mp-labels { pointer-events: none; }
.mp-boundary { fill: #a7b3bd; stroke: #a27631; stroke-width: 2; vector-effect: non-scaling-stroke; }
.mp-road { fill: #8896a2; }
.mp-road-center { fill: none; stroke: #fff8df; stroke-width: 3; stroke-dasharray: 9 8; }
.mp-green { fill: #8eae83; }
.mp-lot { stroke: #f0f6fa; stroke-width: .8; vector-effect: non-scaling-stroke; cursor: pointer; }
.mp-hovered, .mp-selected { stroke: #674417; stroke-width: 2.25; }
.mp-part, .mp-footprint { pointer-events: none; stroke: #f0f6fa; stroke-width: 1; vector-effect: non-scaling-stroke; }
.mp-driveway, .mp-traffic { pointer-events: none; }
.mp-vehicle { stroke: #142b43; stroke-width: .65; }
.mp-vehicle-cab { fill: #dfe9ed; stroke: #183c58; stroke-width: .75; }
.mp-cut { stroke: #172e4d; stroke-width: 3; stroke-dasharray: 7 4; cursor: ew-resize; pointer-events: stroke; touch-action: none; }
.mp-cut-hit { stroke: transparent; stroke-width: 26; stroke-dasharray: none; }
.mp-road-label, .mp-plot-label, .mp-part-label {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 700;
}
.mp-road-label { color: #fff; background: #42546b; border-radius: 4px; padding: 1px 4px; }
.mp-plot-label { color: #0d2347; text-shadow: 0 1px 3px #fff, 0 0 2px #fff; }
.mp-part-label {
  background: #f9fcff;
  border-left: 4px solid var(--part-color);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10px;
}
.mp-dimension-guide {
  fill: none;
  stroke: #193b58;
  stroke-opacity: .75;
  stroke-width: 1.15;
}
.mp-frontage-guide { fill: none; stroke: #096d73; stroke-width: 3; stroke-linecap: round; }
.mp-lot-dimensions, .mp-dimension-label { display: grid; line-height: 1.2; gap: 2px; }
.mp-lot-dimensions { text-align: center; }
.mp-lot-dimensions span { font-weight: 500; color: #193b58; font-size: .86em; }
.mp-dimension-label { padding: 4px 7px; white-space: nowrap; }
.mp-dimension-size span { white-space: nowrap; }
.mp-frontage-label { color: #07595f; font-size: .92em; }
.mp-tip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  max-width: calc(100% - 16px);
  padding: 7px 10px;
  border-radius: 8px;
  background: #0d2347;
  color: #fff;
}
.mp-legend {
  position: absolute;
  z-index: 2;
  left: 10px;
  top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  max-width: calc(100% - 20px);
  margin: 0;
  padding: 6px 9px;
  border: 1px solid #c4d0dd;
  border-radius: 8px;
  background: var(--mp-glass);
  list-style: none;
  pointer-events: none;
  font-size: 12px;
}
.mp-legend li { display: flex; align-items: center; gap: 4px; }
.mp-legend i, .mp-parts li::before {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--swatch); border: 1px solid #586c80;
}
.mp-panel {
  position: absolute;
  z-index: 3;
  right: 12px;
  top: 12px;
  width: min(300px, 44%);
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--mp-glass);
  backdrop-filter: blur(16px);
  border: 1px solid #bbcbdc;
  border-radius: 15px;
  box-shadow: 0 10px 26px #0d234729;
  animation: mp-sheet-in .22s ease-out both;
}
@keyframes mp-sheet-in { from { opacity: 0; transform: translateY(12px); } }
.mp-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 0 14px;
}
.mp-panel h3 { margin: 0; font: 700 28px/1 var(--display, system-ui, sans-serif); }
.mp-panel-head button { min-width: 44px; font-size: 21px; }
.mp-panel-body { padding: 9px 14px 14px; overflow: auto; overscroll-behavior: contain; }
.mp-panel dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 5px 9px; margin: 0; }
.mp-panel dt { color: var(--mp-muted); }
.mp-panel dd { margin: 0; font-weight: 600; }
.mp-distances { display: grid; gap: 2px; margin: 9px 0; padding-top: 8px; border-top: 1px solid #c7d3e0; }
.mp-action, .mp-viewer .mp-action { display: inline-flex; align-items: center; background: #0d2347; color: white; text-decoration: none; }
.mp-viewer button.mp-action:hover:not(:disabled) { background: #24446b; }
.mp-work { display: grid; gap: 9px; margin-top: 10px; padding-top: 9px; border-top: 1px solid #c7d3e0; }
.mp-work p { margin: 0; }
.mp-work input[type="range"] { width: 100%; padding: 0; accent-color: var(--mp-accent); }
.mp-note { color: var(--mp-muted); font-size: 12px; }
.mp-error { color: #a12228; font-weight: 600; }
.mp-error:empty { display: none; }
.mp-parts { margin: 0; padding: 0; list-style: none; }
.mp-parts li { display: flex; align-items: center; gap: 6px; }
.mp-parts li::before { content: ''; flex: 0 0 10px; }
.mp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.mp-status { margin: 8px 0 0; color: var(--mp-muted); min-height: 1.45em; }
.mp-a11y {
  position: absolute;
  z-index: 4;
  left: 8px;
  top: 45px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.mp-a11y button:not(:focus) { position: absolute; width: 1px; min-height: 0; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; }
.mp-a11y button:focus { position: relative; }
.mp-sheet-grip { display: none; }
@media (max-width: 700px) {
  .mp-stage { height: 70vh; height: 70svh; min-height: 380px; }
  .mp-sheet-open .mp-map { width: 100%; top: 40px; height: calc(55% - 40px); }
  .mp-toolbar { gap: 6px; padding: 8px; }
  .mp-toolbar label { flex: 1 1 125px; }
  .mp-toolbar button { flex: 1 1 auto; }
  .mp-panel { top: auto; right: 0; bottom: 0; width: 100%; max-height: 45%; border-radius: 15px 15px 0 0; }
  .mp-sheet-grip { display: grid; place-items: center; flex: 0 0 21px; touch-action: none; cursor: grab; }
  .mp-sheet-grip::before { content: ''; width: 38px; height: 4px; border-radius: 9px; background: #7e92a9; }
  .mp-panel-head { padding-top: 0; }
  .mp-plot-label, .mp-road-label { font-size: 9px; }
  .mp-part-label { font-size: 9px; max-width: 140px; white-space: normal; }
  .mp-lot-dimensions span { font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) { .mp-panel { animation: none; } }
