/* Sequencer module — prefix `sq-`. Tokens only (no raw hex; theme-switch safe).
 * Layout: library LEFT + gantt RIGHT, draggable divider. Foundation scope. */

.sq-wrap { display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 420px; }

/* Header row: mode pill, engine badge, zoom, keymap hint */
.sq-head { display: flex; align-items: center; gap: 10px; padding: 6px 38px 8px 2px; flex-wrap: wrap; position: relative; }
/* Gear pinned upper-right regardless of header wrapping (view config always
   lives where people expect it). */
.sq-head .sq-gearbtn { position: absolute; top: 5px; right: 2px; }
.sq-head .sq-title { font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.sq-pill {
  font-size: 12px; padding: 4px 10px; border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md); cursor: pointer; user-select: none;
  color: var(--color-text-secondary); background: var(--surface-2);
}
.sq-pill:hover { border-color: var(--accent); color: var(--color-text-primary); }
/* Job-scope picker (S70-SYNC.11) is a native <select> wearing the pill look. */
select.sq-jobscope { font-family: inherit; max-width: 160px; }
select.sq-jobscope:hover { border-color: var(--accent); color: var(--color-text-primary); }
.sq-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 100px; font-family: var(--font-mono);
  background: var(--color-background-info); color: var(--color-text-info);
}
.sq-badge.stub { background: var(--st-planned-bg); color: var(--color-text-warn); }
.sq-spacer { flex: 1 1 auto; }
.sq-zoombtn {
  min-width: 26px; height: 26px; border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md); background: var(--surface-2);
  color: var(--color-text-secondary); cursor: pointer; font-size: 13px;
}
.sq-zoombtn:hover { border-color: var(--accent); color: var(--color-text-primary); }
.sq-keymap {
  font-size: 10px; color: var(--color-text-tertiary); font-family: var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sq-keymap kbd {
  font-family: var(--font-mono); font-size: 10px; padding: 0 4px; border-radius: 3px;
  background: var(--surface-3); color: var(--color-text-secondary);
  border: 1px solid var(--color-border-tertiary);
}

/* Body: library | divider | gantt */
.sq-body { display: flex; flex: 1 1 auto; min-height: 0; border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-lg); overflow: hidden; }

/* ── Library pane ────────────────────────────────────────────────────────── */
.sq-lib { flex: 0 0 auto; width: 280px; min-width: 160px; max-width: 520px; display: flex; flex-direction: column; background: var(--surface-1); border-right: 1px solid var(--color-border-secondary); }
.sq-lib-h { padding: 8px 10px; font-size: 12px; color: var(--color-text-secondary); border-bottom: 1px solid var(--color-border-secondary); }
.sq-search-wrap { padding: 6px 8px; border-bottom: 1px solid var(--color-border-secondary); }
.sq-search { width: 100%; padding: 5px 8px; font-size: 12px; border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-md); background: var(--surface-2); color: var(--color-text-primary); outline: none; box-sizing: border-box; }
.sq-search:focus { border-color: var(--accent); }
.sq-search::placeholder { color: var(--color-text-tertiary); }
.sq-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--color-border-secondary); }
.sq-list { flex: 1 1 auto; overflow-y: auto; padding: 4px; }
.sq-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin: 2px 0;
  border-radius: var(--border-radius-md); cursor: grab; background: var(--surface-2);
  border: 1px solid transparent;
}
.sq-row:hover { border-color: var(--color-border-secondary); background: var(--hover-bg); }
.sq-row.dragging { opacity: 0.35; }
.sq-row.in-use { opacity: 0.45; }
.sq-row.in-use:hover { opacity: 0.8; }
.sq-inuse-chip { font-size: 8px; padding: 0 4px; border-radius: 3px; background: var(--surface-2); color: var(--color-text-tertiary); border: 1px solid var(--color-border-secondary); text-transform: uppercase; letter-spacing: 0.3px; }
.sq-row .sq-grip { color: var(--color-text-tertiary); font-size: 11px; cursor: grab; }
.sq-row .sq-name { flex: 1 1 auto; font-size: 12px; color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sq-row .sq-meta { font-size: 10px; color: var(--color-text-tertiary); }
.sq-kind, .sq-src {
  font-size: 9px; padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.3px;
}
.sq-src { background: var(--surface-3); color: var(--color-text-secondary); }
.sq-kind { color: var(--accent-text); }
.sq-kind.task { background: var(--st-active-bg); color: var(--color-text-info); }
.sq-kind.event { background: var(--st-planned-bg); color: var(--color-text-warn); }
.sq-kind.project { background: var(--st-next-bg); color: var(--color-text-info); }
.sq-kind.milestone { background: var(--st-done-bg); color: var(--color-text-success); }
.sq-kind.job { background: var(--st-done-bg); color: var(--color-text-success); }
.sq-kind.phase { background: var(--st-next-bg); color: var(--color-text-info); }
.sq-kind.inspection { background: var(--st-blocked-bg); color: var(--st-blocked); }
.sq-kind.procurement { background: var(--st-active-bg); color: var(--color-text-warn); }
.sq-kind.punch { background: var(--st-planned-bg); color: var(--st-planned); }

/* Divider */
.sq-divider { flex: 0 0 6px; cursor: col-resize; background: var(--color-border-secondary); }
.sq-divider:hover { background: var(--accent); }

/* ── Gantt pane ──────────────────────────────────────────────────────────── */
.sq-gantt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.sq-axis { position: relative; height: 22px; border-bottom: 1px solid var(--color-border-secondary); background: var(--surface-1); overflow: hidden; flex: 0 0 auto; }
.sq-tick { position: absolute; top: 0; height: 100%; font-size: 10px; color: var(--color-text-tertiary); font-family: var(--font-mono); padding-left: 4px; border-left: 1px solid var(--color-border-tertiary); box-sizing: border-box; white-space: nowrap; }
.sq-tick.major { border-left-color: var(--color-border-secondary); color: var(--color-text-secondary); font-weight: 600; }
.sq-tick.minor { border-left-color: var(--color-border-tertiary); opacity: 0.5; }
.sq-canvas { position: relative; flex: 1 1 auto; overflow: hidden; }
.sq-lanes { position: absolute; top: 0; left: 0; right: 0; }
.sq-nonwork { position: absolute; top: 0; bottom: 0; background: var(--st-planned-bg); pointer-events: none; z-index: 0; }

.sq-lane { position: relative; min-height: 48px; border-bottom: 1px solid var(--color-border-tertiary); }
.sq-lane-h {
  position: absolute; left: 0; top: 0; z-index: 3; height: 24px; line-height: 24px;
  padding: 0 10px; font-size: 12px; color: var(--color-text-secondary);
  background: var(--surface-1); border-right: 1px solid var(--color-border-secondary);
  border-bottom-right-radius: var(--border-radius-md); white-space: nowrap; pointer-events: auto;
  display: flex; align-items: center; gap: 4px;
}
.sq-lane-h .sq-adhoc { font-size: 8px; margin-left: 4px; padding: 0 4px; border-radius: 3px; background: var(--st-planned-bg); color: var(--color-text-warn); }
.sq-lane-caret {
  background: none; border: none; color: var(--color-text-tertiary); font-size: 9px; cursor: pointer;
  padding: 0 2px; line-height: 1; border-radius: 3px;
}
.sq-lane-caret:hover { color: var(--color-text-primary); background: var(--hover-bg); }
.sq-lane-x {
  background: none; border: none; color: var(--color-text-tertiary); font-size: 14px; cursor: pointer;
  padding: 0 2px; line-height: 1; margin-left: 2px; border-radius: 3px; opacity: 0;
  transition: opacity 0.15s;
}
.sq-lane-h:hover .sq-lane-x { opacity: 1; }
.sq-lane-x:hover { color: var(--color-text-danger); background: var(--color-background-danger); }
.sq-lane.drop-over { background: var(--color-background-info); }
.sq-lane-track { position: relative; height: 100%; }

.sq-nowline { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--color-text-danger); pointer-events: none; z-index: 2; }

/* Bars */
.sq-bar {
  position: absolute; height: 24px; border-radius: 4px; padding: 0 8px; font-size: 11px;
  line-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-sizing: border-box; cursor: pointer; z-index: 1; color: var(--accent-text);
  border: 1px solid transparent;
}
.sq-bar.k-task { background: var(--st-active); }
.sq-bar.k-event { background: var(--st-planned); cursor: not-allowed; opacity: 0.92; }
.sq-bar.k-project { background: var(--st-next); }
.sq-bar.k-milestone { background: transparent; }
.sq-bar.k-job { background: var(--st-done); }
.sq-bar.k-phase { background: var(--st-next); opacity: 0.7; border: 1px dashed var(--st-next); }
.sq-bar.k-inspection { background: var(--st-blocked); }
.sq-bar.k-procurement { background: var(--st-active); opacity: 0.8; border-style: dotted; }
.sq-bar.k-punch { background: var(--st-planned); border: 1px solid var(--st-planned); }
.sq-bar.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.sq-bar.offpath { opacity: 0.28; }
.sq-bar .sq-fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,0.22); border-radius: 3px 0 0 3px; pointer-events: none; }
.sq-bar .sq-slack { position: absolute; right: 0; top: 0; bottom: 0; transform: translateX(100%); background: var(--accent); opacity: 0.12; border-radius: 0 3px 3px 0; pointer-events: none; }
.sq-bar .sq-conf-zone { position: absolute; right: 0; top: 2px; bottom: 2px; transform: translateX(100%); background: var(--color-text-warn); opacity: 0.18; border-radius: 0 3px 3px 0; pointer-events: none; border: 1px dashed var(--color-text-warn); }

/* Edge-drag dep handle: visible grip at the bar's right edge on hover */
.sq-bar .sq-linkdot {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box;
  background: var(--surface-1); border: 2px solid var(--accent);
  cursor: crosshair; opacity: 0; transition: opacity 0.12s, transform 0.12s; z-index: 2;
}
.sq-bar .sq-linkdot.start { left: 3px; right: auto; }
.sq-bar:hover .sq-linkdot { opacity: 1; }
.sq-bar .sq-linkdot:hover { transform: translateY(-50%) scale(1.3); }
/* Live dep-type readout following the cursor during an edge drag */
.sq-deptype-tip {
  position: fixed; z-index: 10000; pointer-events: none; display: none;
  font-size: 10px; font-family: var(--font-mono); font-weight: 700;
  padding: 2px 6px; border-radius: 3px;
  background: var(--accent); color: var(--accent-text);
}
.sq-deptype-tip.shown { display: block; }
.sq-bar.resizing { cursor: ew-resize; opacity: 0.85; }
.sq-templine { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 9999; }
.sq-templine path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }
.sq-bar.dep-target, .sq-milestone.dep-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
/* milestone diamond */
.sq-milestone { position: absolute; width: 12px; height: 12px; transform: rotate(45deg); background: var(--st-done); z-index: 1; cursor: pointer; }
.sq-milestone.selected { outline: 1px solid var(--accent); outline-offset: 1px; }

/* Warning-class alert marker */
.sq-alert {
  position: absolute; width: 14px; height: 14px; border-radius: 50%; z-index: 4;
  background: var(--color-background-warn); color: var(--color-text-warn);
  border: 1px solid var(--color-text-warn); font-size: 10px; line-height: 12px;
  text-align: center; cursor: help; font-weight: 700;
}
/* Off-view directional alert counters at lane edges */
.sq-edge-alert {
  position: absolute; top: 2px; z-index: 5; font-size: 9px; font-family: var(--font-mono);
  padding: 1px 5px; border-radius: 100px; background: var(--color-background-warn);
  color: var(--color-text-warn); border: 1px solid var(--color-text-warn); pointer-events: none;
}
.sq-edge-alert.left { left: 4px; }
.sq-edge-alert.right { right: 4px; }

/* Staleness tick */
.sq-stale { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--color-text-warn); margin-left: 4px; vertical-align: middle; }

/* SVG connector layer */
.sq-conn { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.sq-conn path { stroke: var(--color-text-tertiary); stroke-width: 1.2; fill: none; }
.sq-conn path.soft { stroke-dasharray: 3 3; }
.sq-conn .sq-arrow { fill: var(--color-text-tertiary); }

/* Dep-type distinguishability: FS keeps the tertiary default */
.sq-conn path.t-ss { stroke: var(--st-planned); }
.sq-conn path.t-ff { stroke: var(--st-next); }
.sq-conn path.t-sf { stroke: var(--color-text-warn); }
.sq-conn .sq-arrow.t-ss { fill: var(--st-planned); }
.sq-conn .sq-arrow.t-ff { fill: var(--st-next); }
.sq-conn .sq-arrow.t-sf { fill: var(--color-text-warn); }

/* Hover emphasis (paired to the .sq-connector hit path via data-k) */
.sq-conn path.hot { stroke: var(--accent); stroke-width: 2.2; }
.sq-conn .sq-arrow.hot { fill: var(--accent); }
.sq-bar.dep-endpoint { box-shadow: 0 0 0 2px var(--accent); }

/* Cross-lane connector overlay (spans the whole lanes container) */
.sq-conn-x { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none; overflow: visible; }
.sq-conn path.xlane { opacity: 0.75; }

/* Lag labels on connector corridors */
.sq-conn .sq-laglbl { font-size: 9px; font-family: var(--font-mono); fill: var(--color-text-secondary); stroke: none; paint-order: stroke; }

/* Chain highlight on bar hover: dim everything outside the hovered chain */
.sq-bar.chain-dim, .sq-milestone.chain-dim { opacity: 0.18; transition: opacity 0.15s; }
.sq-conn path.chain-hot { stroke: var(--accent); }
.sq-conn .sq-arrow.chain-hot { fill: var(--accent); }

/* Ghost bar + snap tooltip (drag-to-place preview) */
.sq-ghost {
  position: absolute; height: 20px; border-radius: 3px; padding: 0 6px; font-size: 11px;
  line-height: 18px; white-space: nowrap; pointer-events: none; z-index: 6; display: none;
  border: 1.5px dashed var(--color-text-info); background: var(--color-background-info);
  color: var(--color-text-info); box-sizing: border-box; overflow: hidden; text-overflow: ellipsis;
}
.sq-ghost.shown { display: block; }
.sq-snaptip {
  position: absolute; z-index: 7; font-size: 10px; font-weight: 500; pointer-events: none;
  background: var(--color-text-info); color: var(--accent-text); padding: 2px 6px;
  border-radius: 3px; white-space: nowrap; display: none;
}
.sq-snaptip.shown { display: block; }

/* Conflict popover */
.sq-conflict-ov { position: fixed; inset: 0; z-index: 200; background: var(--scrim); display: flex; align-items: center; justify-content: center; }
.sq-conflict {
  width: min(420px, 92vw); background: var(--surface-1); border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-lg); box-shadow: var(--shadow-2); padding: 16px;
}
.sq-conflict h4 { margin: 0 0 4px; font-size: 14px; color: var(--color-text-primary); display: flex; align-items: center; gap: 8px; }
.sq-conflict .sq-warn-ic { width: 18px; height: 18px; border-radius: 50%; background: var(--color-background-warn); color: var(--color-text-warn); text-align: center; line-height: 18px; font-weight: 700; }
.sq-conflict p { font-size: 12px; color: var(--color-text-secondary); margin: 6px 0 12px; }
.sq-cbtn {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  text-align: left; padding: 10px 12px; margin: 6px 0; border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border-secondary); background: var(--surface-2);
  color: var(--color-text-primary); cursor: pointer; font-size: 13px;
}
.sq-cbtn:hover { border-color: var(--accent); }
.sq-cbtn.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.sq-cbtn.cancel { color: var(--color-text-secondary); }
.sq-cbtn .sq-rec { font-size: 10px; opacity: 0.85; }

.sq-empty { padding: 24px; color: var(--color-text-tertiary); font-size: 12px; text-align: center; }

/* Drafts subsection (event-conflict "propose new event time") */
.sq-drafts { border-top: 1px solid var(--color-border-secondary); padding: 4px; }
.sq-drafts-h { padding: 6px 8px; font-size: 11px; color: var(--color-text-secondary); }
.sq-draft-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin: 2px 0;
  border-radius: var(--border-radius-md); background: var(--surface-2);
  border: 1px dashed var(--color-text-warn);
}
.sq-draft-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.3px;
  background: var(--st-planned-bg); color: var(--color-text-warn);
}
.sq-draft-name { flex: 1 1 auto; font-size: 12px; color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sq-draft-reason { font-size: 10px; color: var(--color-text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.sq-draft-dismiss {
  border: none; background: transparent; color: var(--color-text-tertiary); cursor: pointer;
  font-size: 11px; line-height: 1; padding: 2px 4px;
}
.sq-draft-dismiss:hover { color: var(--color-text-danger); }

/* Gantt "new item" create modal */
.sq-create-ov { position: fixed; inset: 0; z-index: 200; background: var(--scrim); display: flex; align-items: center; justify-content: center; }
.sq-create {
  width: min(420px, 92vw); max-height: 86vh; overflow-y: auto; background: var(--surface-2);
  border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-2); padding: 16px;
}
.sq-create h4 { margin: 0 0 12px; font-size: 14px; color: var(--color-text-primary); }
.sq-flabel {
  display: flex; flex-direction: column; gap: 4px; font-size: 11px;
  color: var(--color-text-secondary); margin: 0 0 10px;
}
.sq-req { color: var(--color-text-danger); }
.sq-finput {
  padding: 6px 8px; font-size: 12px; border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md); background: var(--surface-1); color: var(--color-text-primary);
  outline: none; box-sizing: border-box; width: 100%;
}
.sq-finput:focus { border-color: var(--accent); }
.sq-finput::placeholder { color: var(--color-text-tertiary); }
.sq-warn-row {
  font-size: 11px; color: var(--color-text-warn); background: var(--st-planned-bg);
  border-radius: var(--border-radius-md); padding: 6px 8px; margin: 4px 0 10px;
}
.sq-create-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.sq-create-actions .sq-cbtn { width: auto; }
.sq-create-actions .sq-cbtn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Context menus (bars, dep connectors, lane headers) */
.sq-ctxmenu {
  position: fixed; z-index: 250; min-width: 180px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md); box-shadow: var(--shadow-2, 0 4px 16px rgba(0,0,0,0.25));
}
.sq-ctx-item {
  padding: 7px 10px; font-size: 12px; color: var(--color-text-primary);
  border-radius: var(--border-radius-md); cursor: pointer; white-space: nowrap;
}
.sq-ctx-item:hover { background: var(--surface-3); }
.sq-ctx-item.danger { color: var(--color-text-danger); }
.sq-ctx-sep { height: 1px; margin: 4px 2px; background: var(--color-border-secondary); }

/* View-config popover (gear) */
.sq-viewcfg {
  position: fixed; z-index: 1000; min-width: 220px;
  background: var(--surface-1); border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-lg); box-shadow: var(--shadow-2, 0 8px 24px rgba(0,0,0,0.35));
  padding: 10px 12px;
}
.sq-viewcfg .sq-cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.sq-viewcfg .sq-cfg-label { font-size: 12px; color: var(--color-text-secondary); }
.sq-seg { display: inline-flex; border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-md); overflow: hidden; }
.sq-seg-btn { border: none; background: var(--surface-2); color: var(--color-text-secondary); font-size: 11px; padding: 4px 10px; cursor: pointer; }
.sq-seg-btn + .sq-seg-btn { border-left: 1px solid var(--color-border-secondary); }
.sq-seg-btn.active { background: var(--accent); color: var(--accent-text); }
.sq-seg-btn:hover:not(.active) { background: var(--hover-bg); color: var(--color-text-primary); }
/* Work-calendar config (gear popover) */
.sq-calrow { display: flex; flex-wrap: wrap; gap: 8px; max-width: 180px; }
.sq-cal-day { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--color-text-secondary); cursor: pointer; }
.sq-cal-exceptions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; max-width: 180px; }
.sq-cal-exc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.sq-cal-exc-txt { font-size: 11px; color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* In-page prompt (window.prompt is blocked in iOS standalone PWAs) */
.sq-promptbox { display: flex; flex-direction: column; gap: 8px; width: 280px; }
.sq-promptbox .sq-cfg-label { white-space: pre-line; }
.sq-promptbox .sq-cfg-row { justify-content: flex-end; }

/* Proximity dep-authoring: highlight the chosen source bar while awaiting the target click */
.sq-bar.dep-source, .sq-milestone.dep-source {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* Visible "Connect" toggle — auto-width variant of .sq-zoombtn, highlighted while active */
.sq-depdraw-btn { width: auto; padding: 0 10px; }
.sq-depdraw-btn.active {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
}
.sq-depdraw-banner {
  font-size: 12px; padding: 6px 10px; margin: 0 0 6px; border-radius: var(--border-radius-md);
  background: var(--color-background-info); color: var(--color-text-info);
}
/* While connecting, every clickable task reads as a target, not a drag handle */
.sq-wrap.dep-mode .sq-bar:not(.k-event), .sq-wrap.dep-mode .sq-milestone { cursor: crosshair; }

/* Dep connector hit-area: transparent wide stroke so right-click is easy to land,
   layered over the visible thin path already drawn in .sq-conn. */
.sq-connector { stroke: transparent; stroke-width: 10; fill: none; pointer-events: stroke; cursor: context-menu; }

/* Cascade ghost preview: downstream bars shown at their would-be position pre-commit */
.sq-ghost-bar {
  position: absolute; height: 20px; border-radius: 3px; padding: 0 6px; font-size: 11px;
  line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-sizing: border-box; opacity: 0.3; border: 1px dashed var(--accent);
  color: var(--color-text-primary); pointer-events: none; z-index: 5;
}

/* ── iPad / tablet responsive (S5-WEB.5) ───────────────────────────────── */
@media (max-width: 1024px) {
  .sq-body { flex-direction: column; }
  .sq-lib {
    width: 100% !important; max-width: none; min-width: 0;
    max-height: 220px; border-right: none;
    border-bottom: 1px solid var(--color-border-secondary);
  }
  .sq-divider { flex: 0 0 6px; cursor: row-resize; width: 100%; height: 6px; }
  .sq-gantt { min-height: 200px; }
  .sq-keymap { display: none; }
  .sq-head { gap: 6px; }
}
@media (max-width: 768px) {
  .sq-lib { max-height: 180px; }
  .sq-head { flex-wrap: wrap; gap: 4px; }
  .sq-pill { font-size: 11px; padding: 3px 6px; }
  .sq-zoombtn { min-width: 22px; height: 22px; font-size: 12px; }
  .sq-row .sq-meta { display: none; }
  .sq-chips { gap: 3px; padding: 4px 6px; }
}

/* Edge-drag sidebar collapse: library collapses to a 36px handle when narrow */
.sq-lib.collapsed { max-height: 36px; overflow: hidden; cursor: pointer; }
.sq-lib.collapsed .sq-list,
.sq-lib.collapsed .sq-chips,
.sq-lib.collapsed .sq-search-wrap,
.sq-lib.collapsed .sq-drafts { display: none; }
.sq-lib.collapsed .sq-lib-h { cursor: pointer; }

/* Change history in detail view */
.sq-hist-title { margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--fg); }
.sq-hist-loading, .sq-hist-empty { font-size: 12px; color: var(--fg-muted); padding: 8px 0; }
.sq-hist-list { display: flex; flex-direction: column; gap: 10px; }
.sq-hist-entry { border-left: 2px solid var(--border); padding-left: 10px; }
.sq-hist-meta { font-size: 11px; color: var(--fg-muted); margin-bottom: 2px; }
.sq-hist-who { font-weight: 600; color: var(--fg); }
.sq-hist-what { font-size: 12px; color: var(--fg); line-height: 1.5; }
.sq-hist-field { font-weight: 600; color: var(--accent); }
.sq-hist-from { color: var(--fg-muted); text-decoration: line-through; }
.sq-hist-to { color: var(--fg); }

/* ── compact bottom detail drawer ─────────────────────────────────────────── */
.sq-drawer {
  display: flex; align-items: center; gap: 14px; padding: 8px 12px;
  border-top: 1px solid var(--color-border-secondary);
  background: var(--surface-1); flex: 0 0 auto;
  overflow-x: auto; white-space: nowrap;
}
.sq-dw-name {
  font-size: 13px; font-weight: 600; color: var(--color-text-primary);
  overflow: hidden; text-overflow: ellipsis; max-width: 280px;
}
.sq-dw-field {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--color-text-secondary);
}
.sq-dw-val {
  font-family: var(--font-mono); color: var(--color-text-primary);
  min-width: 44px; text-align: center;
}
.sq-dw-step, .sq-dw-btn {
  min-width: 22px; height: 22px; border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md); background: var(--surface-2);
  color: var(--color-text-secondary); cursor: pointer; font-size: 11px;
  padding: 0 6px;
}
.sq-dw-step:hover, .sq-dw-btn:hover { border-color: var(--accent); color: var(--color-text-primary); }
.sq-dw-btn.danger { color: var(--color-text-danger); }
.sq-dw-close { margin-left: auto; }

/* ── 2-week lookahead list view ─────────────────────────────────────────────── */
.sq-zoombtn.active-look { border-color: var(--accent); color: var(--accent-text); background: var(--accent); }
.sq-look { flex: 1 1 auto; overflow-y: auto; padding: 12px 16px; background: var(--bg); }
.sq-look-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.sq-look-title-main { font-size: 14px; font-weight: 700; color: var(--color-text-primary); }
.sq-look-sub { font-size: 11px; font-family: var(--font-mono); color: var(--color-text-tertiary); }
.sq-look-head .sq-zoombtn { margin-left: auto; }
.sq-look-lane { margin-bottom: 16px; }
.sq-look-lane-h {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border-secondary);
  padding-bottom: 4px;
  margin-bottom: 4px;
}
.sq-look-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-primary);
}
.sq-look-item:hover { background: var(--hover-bg); }
.sq-look-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--st-planned); }
.sq-look-dot.active { background: var(--st-active); }
.sq-look-dot.done { background: var(--st-done); }
.sq-look-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sq-look-meta { font-family: var(--font-mono); font-size: 11px; color: var(--color-text-tertiary); }
.sq-look-warn {
  color: var(--color-text-warn);
  font-size: 10px;
  border: 1px solid var(--color-text-warn);
  border-radius: 3px;
  padding: 0 4px;
}
.sq-look-none, .sq-look-empty { font-size: 11px; color: var(--color-text-tertiary); padding: 4px 8px; }

/* ── full-timeline gantt view (one row per task) ───────────────────────────── */
/* Single vertical scroller wraps both columns so labels + timeline scroll
   together; the timeline scrolls horizontally on its own (#sq-canvas). */
.sq-gf { display: flex; flex: 1 1 auto; min-height: 0; overflow-y: auto; align-items: flex-start; }
.sq-gf-labels {
  flex: 0 0 210px; position: sticky; left: 0; z-index: 3;
  background: var(--surface-1); border-right: 1px solid var(--color-border-secondary);
}
.sq-gf-tools {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 6px; box-sizing: border-box;
  background: var(--surface-1); border-bottom: 1px solid var(--color-border-secondary);
}
.sq-gf-toolbtn {
  height: 16px; line-height: 14px; padding: 0 6px; font-size: 9px;
  border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-md);
  background: var(--surface-2); color: var(--color-text-secondary); cursor: pointer;
}
.sq-gf-toolbtn:hover { border-color: var(--accent); color: var(--color-text-primary); }
.sq-gf-group {
  height: 24px; line-height: 24px; padding: 0 8px; box-sizing: border-box;
  font-size: 11px; font-weight: 700; color: var(--color-text-secondary);
  background: var(--surface-2); border-bottom: 1px solid var(--color-border-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sq-gf-label {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px;
  box-sizing: border-box; font-size: 12px; color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-tertiary); cursor: pointer;
}
.sq-gf-label:hover { background: var(--hover-bg); }
.sq-gf-label-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sq-gf-timeline { flex: 1 1 auto; min-width: 0; overflow-x: auto; position: relative; background: var(--bg); }
.sq-gf-timeline .sq-axis { position: sticky; top: 0; z-index: 4; }
.sq-gf-canvas { position: relative; }
.sq-gf-group-track { height: 24px; box-sizing: border-box; background: var(--surface-2); opacity: 0.5; border-bottom: 1px solid var(--color-border-tertiary); }
.sq-gf-row { position: relative; height: 32px; box-sizing: border-box; border-bottom: 1px solid var(--color-border-tertiary); }
.sq-gf-row.drop-over { background: var(--hover-bg); }
.sq-gf-track { position: relative; height: 100%; }
/* Baseline ghost: render-only snapshot bar peeking below the live bar */
.sq-gf-ghost {
  position: absolute; top: 24px; height: 6px; border-radius: 3px;
  background: var(--color-text-tertiary); opacity: 0.45; pointer-events: none; z-index: 0;
}

/* Baseline slip/gain badge: end-of-bar delta indicator (§ dynamic baseline diff) */
.sq-slip { position: absolute; right: 2px; top: -1px; font-size: 9px; padding: 0 3px; border-radius: 2px; pointer-events: none; white-space: nowrap; }
.sq-slip.slip { background: var(--st-blocked-bg); color: var(--st-blocked); }
.sq-slip.gain { background: var(--st-done-bg); color: var(--st-done); }
/* In the library row (flex layout, not a positioned bar) the badge flows inline instead */
.sq-row .sq-slip { position: static; margin-left: auto; flex: 0 0 auto; }
.sq-gf-basesum { font-size: 10px; color: var(--color-text-tertiary); padding: 4px 8px; }

/* ── S3-CRW: Crew & conflicts ──────────────────────────────────────────── */
.sq-crew-sel { min-width: 140px; }
.sq-crew-sel optgroup { font-weight: 600; color: var(--color-text-primary); }

.sq-conflict-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  background: var(--color-background-danger);
  color: var(--color-text-danger);
  vertical-align: middle;
}
.sq-row .sq-conflict-badge { position: static; margin-left: auto; flex: 0 0 auto; }

.sq-conflict-pill {
  background: var(--color-background-danger) !important;
  color: var(--color-text-danger) !important;
}

/* ── S4-SITE.1: Daily Log panel ──────────────────────────────────────── */
.sq-log-panel {
  border-bottom: 1px solid var(--color-border-secondary);
  background: var(--surface-1);
  max-height: 280px;
  overflow-y: auto;
}
.sq-log-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border-secondary);
}
.sq-log-title { font-weight: 600; font-size: 13px; color: var(--color-text-primary); flex: 1; }
.sq-log-form {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border-secondary);
}
.sq-log-textarea {
  width: 100%; resize: vertical;
  font-family: inherit; font-size: 13px;
  margin-top: 6px;
}
.sq-log-form-actions {
  display: flex; gap: 6px; margin-top: 6px;
  justify-content: flex-end;
}
.sq-log-list { padding: 4px 0; }
.sq-log-entry {
  padding: 6px 12px;
  border-bottom: 1px solid var(--color-border-secondary);
}
.sq-log-entry:last-child { border-bottom: none; }
.sq-log-date {
  font-size: 11px; font-weight: 600; color: var(--color-text-secondary);
  display: flex; align-items: center; gap: 6px;
}
.sq-log-photos {
  font-size: 10px; color: var(--accent);
}
.sq-log-text {
  font-size: 13px; color: var(--color-text-primary); margin-top: 2px;
  line-height: 1.4; white-space: pre-wrap;
}
.sq-log-empty {
  padding: 12px; font-size: 12px; color: var(--color-text-secondary); text-align: center;
}

/* ── S4-SITE.2: Punch list close-out ─────────────────────────────────── */
.sq-punch-view { padding: 12px; }
.sq-punch-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.sq-punch-title-main { font-weight: 600; font-size: 14px; color: var(--color-text-primary); flex: 1; }
.sq-punch-progress { font-size: 12px; color: var(--color-text-secondary); }
.sq-punch-bar {
  height: 6px; border-radius: 3px;
  background: var(--color-border-secondary);
  margin-bottom: 12px; overflow: hidden;
}
.sq-punch-fill {
  height: 100%; border-radius: 3px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.sq-punch-list { display: flex; flex-direction: column; gap: 2px; }
.sq-punch-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 4px;
  background: var(--surface-1);
}
.sq-punch-row.done { opacity: 0.6; }
.sq-punch-row.done .sq-punch-title { text-decoration: line-through; }
.sq-punch-check { flex: 0 0 auto; cursor: pointer; }
.sq-punch-title { flex: 1; font-size: 13px; color: var(--color-text-primary); }
.sq-punch-meta { font-size: 11px; color: var(--color-text-secondary); }
.sq-punch-empty { padding: 20px; text-align: center; color: var(--color-text-secondary); font-size: 13px; }
.sq-punch-closeout { white-space: nowrap; }

@media print {
  .sq-lib, .sq-head, .sq-divider { display: none !important; }
  .sq-look { overflow: visible; width: 100%; background: none; }
  .sq-look-head .sq-zoombtn { display: none; }
}
