CREATE TABLE elements (
id INTEGER PRIMARY KEY AUTOINCREMENT,
frame_id INTEGER NOT NULL,
source TEXT NOT NULL,
-- 'ocr' | 'accessibility'
role TEXT NOT NULL,
-- OCR: 'page',
'block',
'paragraph',
'line',
'word'
-- AX: 'AXButton',
'AXTextField',
'AXStaticText',
etc.
text TEXT,
-- element text content (NULL for container nodes)
parent_id INTEGER,
-- self-referential FK for tree hierarchy (NULL = root)
depth INTEGER NOT NULL DEFAULT 0,
-- tree depth (0 = root)
left_bound REAL,
-- normalized 0-1 bounding box
top_bound REAL,
width_bound REAL,
height_bound REAL,
confidence REAL,
-- OCR confidence (0-100),
NULL for AX
sort_order INTEGER NOT NULL DEFAULT 0,
properties TEXT,
-- sibling order within parent
FOREIGN KEY (frame_id) REFERENCES frames(id),
FOREIGN KEY (parent_id) REFERENCES elements(id)
)