.ws { flex: 1; display: grid; min-height: 0; grid-template-rows: auto auto auto auto minmax(0, 1fr) auto; grid-template-columns: 48px minmax(0, 1fr) 332px; grid-template-areas: "top top top" "feat feat feat" "quick quick quick" "rail ribbon side" "rail canvas side" "status status status"; background: var(--bg); position: relative; overflow: hidden; }
.ws-top { grid-area: top; display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 48px; }
.ws-top .name { width: 200px; font-weight: 600; background: transparent; border-color: transparent; }
.ws-top .name:hover, .ws-top .name:focus { border-color: var(--border); background: var(--surface); }
.sep { width: 1px; align-self: stretch; background: var(--border); margin: 4px 4px; }
.ws-quick { grid-area: quick; padding: 6px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.rail { grid-area: rail; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; overflow-y: auto; }
.rail .sep { width: 28px; height: 1px; margin: 4px 0; align-self: auto; }
.cv-wrap { grid-area: canvas; position: relative; min-width: 0; min-height: 0; background: var(--canvas-bg); overflow: hidden; touch-action: none; }
.cv-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.cv-wrap.hand canvas { cursor: grab; } .cv-wrap.panning canvas { cursor: grabbing; } .cv-wrap.select canvas { cursor: default; } .cv-wrap.draw canvas { cursor: crosshair; }
.cv-label { position: absolute; left: 30px; bottom: 8px; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--surface) 88%, transparent); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); pointer-events: none; max-width: calc(100% - 40px); }
.cv-banner { position: absolute; left: 50%; top: 30px; transform: translateX(-50%); z-index: 3; max-width: calc(100% - 60px); }
.cv-empty { position: absolute; inset: 22px 0 0 22px; display: grid; place-items: center; z-index: 2; pointer-events: none; }
.cv-empty .empty-card { pointer-events: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); max-width: 380px; display: grid; gap: 10px; text-align: center; }
.side { grid-area: side; background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; min-height: 0; }
.sec { border-bottom: 1px solid var(--border); }
.sec > summary { list-style: none; cursor: pointer; padding: 9px 12px; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; user-select: none; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary .ico { transition: transform .15s; } .sec:not([open]) > summary .ico { transform: rotate(-90deg); }
.sec > summary .count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12px; }
.sec > .body { padding: 2px 12px 14px; display: grid; gap: 10px; }
.status { grid-area: status; display: flex; align-items: center; gap: 10px; padding: 5px 12px; background: var(--surface); border-top: 1px solid var(--border); min-height: 46px; }
.status .scrub { flex: 1; min-width: 80px; } .status .readout { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); min-width: 112px; }
.status select { width: auto; min-height: 30px; }
.cur-color { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); flex: none; }
.cseq { display: flex; height: 12px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); width: 160px; flex: none; }
.cseq button { border: 0; padding: 0; min-width: 4px; cursor: pointer; } .cseq button:focus-visible { outline-offset: -2px; }
.price-chip { font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.obj { display: grid; grid-template-columns: 26px 26px 18px minmax(0, 1fr); align-items: center; gap: 4px; padding: 2px 4px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.obj:hover { background: var(--surface-2); } .obj.sel { background: var(--accent-soft); border-color: var(--accent); }
.obj .sw, .swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; flex: none; }
.obj .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; } .obj.hid .nm { opacity: .5; text-decoration: line-through; }
.thr { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; text-align: left; width: 100%; }
.thr:hover { background: var(--surface-2); } .thr.sel { background: var(--accent-soft); border-color: var(--accent); }
.thr .swatch { width: 22px; height: 22px; border-radius: 50%; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; margin: 0; } .stats dt { color: var(--muted); } .stats dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.warn-li { padding: 6px 8px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.dl-sec { background: var(--accent-soft); }
.recovery { font-size: 18px; letter-spacing: 1px; padding: 10px; background: var(--surface); border: 2px solid var(--accent); border-radius: 8px; text-align: center; word-break: break-all; user-select: all; }
.toggle-row { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.drawer-btn { display: none; }
.scrim { display: none; }

/* iPad: panels become drawers */
@media (max-width: 1100px) {
  .ws { grid-template-columns: 48px minmax(0, 1fr); grid-template-areas: "top top" "feat feat" "quick quick" "rail ribbon" "rail canvas" "status status"; }
  .side { grid-area: canvas; justify-self: end; width: min(360px, 92vw); z-index: 20; transform: translateX(105%); transition: transform .2s; box-shadow: var(--shadow); visibility: hidden; }
  .ws.drawer-open .side { transform: none; visibility: visible; }
  .ws.drawer-open .scrim { display: block; grid-area: canvas; background: rgba(0,0,0,.35); z-index: 15; }
  .drawer-btn { display: inline-grid; }
  .ws-top .name { width: 140px; }
}
/* phone: streamlined stacked layout */
@media (max-width: 640px) {
  .ws { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto; grid-template-areas: "top" "feat" "quick" "rail" "ribbon" "canvas" "status"; }
  .rail { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--border); padding: 2px 6px; justify-content: flex-start; }
  .rail .sep { width: 1px; height: 24px; margin: 0 4px; }
  .ws-top { flex-wrap: wrap; padding: 6px 8px; gap: 4px; } .ws-top .name { flex: 1 1 120px; width: auto; }
  .ws-top .price-chip, .ws-top .hide-sm { display: none; }
  .status { flex-wrap: wrap; gap: 6px; padding: 6px 8px; } .status .scrub { flex-basis: 100%; order: 5; } .cseq { width: 90px; }
  .side { align-self: end; height: 72%; width: 100%; transform: translateY(105%); border-left: 0; border-top: 1px solid var(--border); border-radius: 14px 14px 0 0; }
  .ws.drawer-open .side { transform: none; }
  .cv-label { left: 8px; font-size: 11px; }
  .slider-row { grid-template-columns: 74px 1fr 52px; }
}

/* Advanced stitch properties (Properties panel) */
.so-block { display: grid; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.so-block .so-title { font-size: 13px; }
.so-guide { align-items: end; flex-wrap: wrap; gap: 6px; }
.so-guide label.field { flex: 1 1 90px; }
.so-error { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Mixed values and subset notes in a multi-object selection */
.so-mixed-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 600; }
.so-mixed-tag[hidden] { display: none; }
.notice.info { background: var(--accent-soft); color: var(--text); }
.so-subset, .so-locked { font-size: 12px; }
.dl-restricted { overflow-wrap: anywhere; }

/* Shapes & layout panel */
.sh-block { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.sh-block:first-child { border-top: 0; padding-top: 0; }
.sh-block h3 { margin: 0; font-size: 13px; }
.sh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.sh-grid .btn { padding: 4px 6px; white-space: normal; text-align: center; line-height: 1.15; }
.sh-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px 8px; }
.sh-swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sh-swatches .sw-btn { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); padding: 0; cursor: pointer; }
.sh-swatches .sw-btn[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--accent); }
.sh-error { white-space: pre-wrap; overflow-wrap: anywhere; }
.sh-hint { min-height: 1.2em; }

/* ---- tools 2: select / group / freehand / measure / nodes, outline preview ---- */
.t2-measures { max-height: 140px; overflow: auto; }
.t2-m { display: flex; align-items: center; gap: 6px; }
.t2-m .nm { flex: 1; min-width: 0; font-size: 12px; }
.t2-live { min-height: 1.2em; }
.sh-preview { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface-2); }
.sh-preview h3 { margin: 0; font-size: 13px; }
.pv-svg { width: 100%; max-height: 220px; background: var(--paper); border: 1px solid var(--border); border-radius: 6px; }
.pv-before { fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.pv-after { fill-opacity: .4; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
