.q-object-host {
  --object-ink: #20362b;
  --object-muted: #40584a;
  --object-green: #2a5440;
  --object-line: #c6d4c5;
  --object-field: #829d89;
  --object-surface: #fffefa;
  box-sizing: border-box;
  margin: 1.2rem auto;
  padding: clamp(.8rem, 2.6vw, 1.6rem);
  max-width: 1240px;
  border: 1px solid var(--object-line);
  border-radius: 18px;
  background: #f5f7f0;
  color: var(--object-ink);
  scroll-margin-top: 96px;
}

.q-object-host *, .q-object-host *::before, .q-object-host *::after { box-sizing: border-box; }
.q-object-host [hidden] { display: none !important; }
.q-object-host h2 { font-size: clamp(1.22rem, 2vw, 1.7rem); margin: .25rem 0 .8rem; }
.q-object-host p { line-height: 1.5; }
.q-object-host a { color: var(--object-green); text-decoration: underline; display: inline-block; margin: .5rem .6rem .5rem 0; }
.q-object-host :focus-visible { outline: 3px solid #145d83; outline-offset: 3px; }

.q-object-host button, .q-object-host select, .q-object-host input[type="number"], .q-object-host input[type="text"] {
  font: inherit;
  min-height: 44px;
  max-width: 100%;
}

.q-object-host button {
  white-space: normal;
  border: 1px solid var(--object-field);
  border-radius: 8px;
  background: var(--object-surface);
  padding: .55rem .65rem;
  color: var(--object-green);
  cursor: pointer;
  line-height: 1.25;
}

.q-object-host button[aria-pressed="true"], .q-object-host [data-object-save] { background: var(--object-green); color: #fff; }
.q-object-host button:disabled { opacity: .52; cursor: default; }
@media (hover: hover) {
  .q-object-host button:hover:not(:disabled) { background: #e5efdf; color: var(--object-ink); }
  .q-object-host button[aria-pressed="true"]:hover:not(:disabled), .q-object-host [data-object-save]:hover:not(:disabled) { background: #214333; color: #fff; }
}

.q-object-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(16rem, 1fr);
  gap: 1rem;
  align-items: start;
}

.q-object-preview, .q-object-controls {
  min-width: 0;
  padding: .8rem;
  border: 1px solid var(--object-line);
  border-radius: 13px;
  background: var(--object-surface);
}

.q-object-view-tools, .q-object-zoom-tools, .q-object-actions, .q-object-view-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
}

.q-object-view-tools, .q-object-view-options, .q-object-actions { font-size: .875rem; }
.q-object-zoom-tools { gap: .25rem; }
.q-object-zoom-tools button { min-width: 44px; }
.q-object-zoom-label { min-width: 3.4rem; text-align: center; color: var(--object-muted); font-variant-numeric: tabular-nums; }
.q-object-host [data-object-status]:empty, .q-object-measure:empty, .q-object-actions:not(:has(button:not([hidden]))) { display: none; }
.q-object-host [data-object-status] {
  margin: .6rem 0;
  padding: .45rem .65rem;
  border-radius: 7px;
  background: #e9f1e6;
  color: var(--object-green);
  overflow-wrap: anywhere;
  font-size: .875rem;
}
.q-object-host [data-object-status][role="alert"], .q-object-conflict { background: #fff1df; color: #7d371e; }

.q-object-canvas {
  display: block;
  width: 100%;
  height: clamp(360px, 46vw, 560px);
  margin-top: .55rem;
  border: 1px solid #adbdac;
  border-radius: 9px;
  background: #f3f4eb;
  touch-action: none;
  user-select: none;
}

.q-object-canvas polygon, .q-object-canvas circle { stroke: #708773; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.q-object-canvas .q-object-target-selected > :is(polygon, circle) { stroke: #2a5d47; stroke-width: 2px; }
.q-object-canvas .q-object-boundary > polygon { stroke: #546957; stroke-width: 1.8px; }
.q-object-canvas .q-object-target, .q-object-canvas .q-object-target-selected { cursor: pointer; }
.q-object-canvas .q-object-item, .q-object-canvas .q-object-selected { cursor: grab; }
.q-object-canvas .q-object-item > polygon { stroke: var(--q-object-color); stroke-width: 1.5px; }
.q-object-canvas .q-object-selected > polygon { stroke: var(--q-object-color); stroke-width: 2.4px; }
.q-object-canvas .q-object-pan, .q-object-canvas.q-object-pan * { cursor: grab; }
.q-object-canvas.q-object-pan:active *, .q-object-canvas.q-object-pan:active { cursor: grabbing; }
.q-object-measure { margin: .45rem 0; color: var(--object-ink); font-size: .9rem; font-weight: 640; overflow-wrap: anywhere; }

.q-object-canvas .q-object-handle-hit { fill: transparent; stroke: none; }
.q-object-canvas .q-object-handle-dot { fill: #fffdfa; stroke: #155c83; stroke-width: 2px; }
.q-object-handle { cursor: crosshair; }
.q-object-handle-icon { fill: none; stroke: #155c83; stroke-width: 1.4px; vector-effect: non-scaling-stroke; pointer-events: none; }
.q-object-handles > line, .q-object-guide, .q-object-grid line, .q-object-canvas .q-object-clearance > polygon {
  stroke: #155c83;
  stroke-width: 1px;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.q-object-grid line { stroke: #54735b; stroke-opacity: .32; stroke-dasharray: 0; }
.q-object-canvas .q-object-clearance > polygon { fill: #e9f3f4; fill-opacity: .5; }
.q-object-guide { stroke-width: 1.6px; }
.q-object-conflict { margin: .5rem 0; border-radius: 7px; padding: .5rem .65rem .5rem 1.55rem; overflow-wrap: anywhere; font-size: .875rem; }
.q-object-conflict:empty { display: none; }

.q-object-view-options { margin-top: .35rem; column-gap: .75rem; }
.q-object-view-options label { display: flex; align-items: center; gap: .4rem; min-height: 44px; }
.q-object-host .q-object-preview .q-object-view-options input[type="checkbox"] {
  accent-color: var(--object-green);
  box-sizing: border-box;
  /* Shared touch form styles apply full-width fields. The label is the touch target here. */
  width: 1rem !important;
  height: 1rem;
  min-width: 1rem;
  min-height: 1rem !important;
  margin: 0;
}
.q-object-actions { margin: .45rem 0; }
.q-object-help { margin: .55rem 0; font-size: .875rem; color: var(--object-muted); }
.q-object-help summary, .q-object-precise > summary { min-height: 44px; padding: .7rem; border-radius: 8px; background: #edf2e9; cursor: pointer; }
.q-object-help p { margin: .5rem .15rem; }

.q-object-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
.q-object-form label { display: flex; flex-direction: column; gap: .25rem; min-width: 0; font-size: .875rem; }
.q-object-form input, .q-object-form select { width: 100%; min-width: 0; padding: .4rem; border: 1px solid var(--object-field); border-radius: 7px; background: white; color: var(--object-ink); }
.q-object-form label:has(select), .q-object-form label:has(input[type="text"]), .q-object-precise { grid-column: 1 / -1; }
.q-object-precise[open] { display: grid; gap: .5rem; grid-template-columns: repeat(2,minmax(0,1fr)); }
.q-object-precise > summary { grid-column: 1 / -1; }
.q-object-list { list-style: none; margin: .45rem 0 0; padding: 0; max-height: 240px; overflow: auto; }
.q-object-list:empty { display: none; }
.q-object-list li { padding: .35rem 0; border-bottom: 1px solid var(--object-line); font-size: .875rem; overflow-wrap: anywhere; }

.q-object-catalog h3 { margin: 0 0 .45rem; font-size: 1rem; }
.q-object-catalog > p { margin: .3rem 0 .65rem; font-size: .875rem; color: var(--object-muted); }
.q-object-categories { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .45rem; }
.q-object-categories button { font-size: .8125rem; padding: .38rem .5rem; }
.q-object-catalog-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .45rem; margin-bottom: .8rem; }
.q-object-catalog-grid button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: .25rem;
  min-width: 0;
  padding: .45rem .3rem;
  touch-action: none;
  font-size: .82rem;
  overflow-wrap: anywhere;
  cursor: grab;
}
.q-object-catalog-grid svg { width: min(100%,2.7rem); aspect-ratio: 1; }
.q-object-suggestions { margin-top: .8rem; padding: .8rem; background: #eaf0e5; border-radius: 10px; }
.q-object-suggestions:not(:has(.q-object-suggestion)) { display: none; }
.q-object-suggestions p { margin: .25rem 0; color: var(--object-muted); font-size: .875rem; }
.q-object-suggestion { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem 0; }
.g5-object-overlay { opacity: .85; }

@media (max-width: 760px) {
  .q-object-host { margin: .8rem auto; width: calc(100% - .8rem); }
  .q-object-workspace { grid-template-columns: minmax(0, 1fr); gap: .65rem; }
  .q-object-controls { display: contents; }
  .q-object-catalog { grid-row: 1; }
  .q-object-catalog-grid { margin-bottom: 0; }
  .q-object-catalog-grid svg { width: min(100%, 2.25rem); }
  .q-object-canvas { height: clamp(255px, 82vw, 390px); }
  .q-object-preview { padding: .45rem; }
  .q-object-view-tools {
    display: grid;
    grid-template-columns: 44px minmax(2.45rem, 1fr) 44px repeat(3, minmax(0, 1fr));
  }
  .q-object-zoom-tools { display: contents; }
  .q-object-view-tools button { min-width: 0; padding-inline: .3rem; }
  .q-object-zoom-label { grid-area: 1 / 2; min-width: 0; }
  [data-object-zoom-out] { grid-area: 1 / 1; }
  [data-object-zoom-in] { grid-area: 1 / 3; }
  [data-object-pan] { grid-area: 1 / 4 / 2 / 7; }
  [data-object-undo] { grid-area: 2 / 1 / 3 / 3; }
  [data-object-redo] { grid-area: 2 / 3 / 3 / 5; }
  [data-object-zoom-reset] { grid-area: 2 / 5 / 3 / 7; }
  .q-object-view-options { column-gap: .48rem; }
  .q-object-host .q-object-form input, .q-object-host .q-object-form select { font-size: 16px; }
  .q-object-suggestion { align-items: stretch; flex-direction: column; }
}
