:root {
    color-scheme: light dark;
    --ie-bg-main: #f8fafc;
    --ie-bg-shell: #ffffff;
    --ie-bg-soft: #f1f5f9;
    --ie-bg-rail: #edf2f7;
    --ie-bg-card: #ffffff;
    --ie-bg-control: #ffffff;
    --ie-bg-hover: #e2e8f0;
    --ie-bg-active: #eff6ff;
    --ie-bg-canvas-a: #f1f5f9;
    --ie-bg-canvas-b: #ffffff;
    --ie-border: #dbe2ea;
    --ie-border-strong: #cbd5e1;
    --ie-border-muted: #e6ecf2;
    --ie-text: #0f172a;
    --ie-text-muted: #475569;
    --ie-text-soft: #64748b;
    --ie-accent: #2563eb;
    --ie-danger: #b91c1c;
}

main {
    padding-top: 0.35rem;
    padding-bottom: 0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    background: var(--ie-bg-main);
    width: 100%;
    max-width: none;
    margin: 0;
}
body {
    background: var(--ie-bg-main);
}
.ie-shell {
    width: 100%;
    margin: 0 auto 0.75rem;
    border: 1px solid var(--ie-border);
    border-radius: 10px;
    background: var(--ie-bg-shell);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}
.ie-menubar {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--ie-border-muted);
    background: var(--ie-bg-main);
    font-size: 0.92rem;
    font-weight: 600;
    position: relative;
}
.ie-menubar-spacer { flex: 1 1 auto; }
.ie-project-indicator {
    color: var(--ie-text);
    padding: 0.1rem 0.25rem;
    font-size: 0.84rem;
    font-weight: 700;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ie-project-indicator.is-project { color: #1d4ed8; }
.ie-project-indicator.is-image { color: var(--ie-text); }
.ie-inline-warning {
    margin-left: 0.8rem;
    color: var(--ie-danger);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}
.ie-theme-toggle {
    border: 1px solid var(--ie-border-strong);
    background: var(--ie-bg-control);
    color: var(--ie-text);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}
.ie-theme-toggle:hover {
    background: var(--ie-bg-hover);
}
.ie-menu-group { position: relative; }
.ie-menu-item {
    border: 0;
    background: transparent;
    padding: 0.35rem 0.45rem;
    color: var(--ie-text);
    cursor: pointer;
    border-radius: 6px;
}
.ie-menu-item:hover,
.ie-menu-item.is-open { background: var(--ie-bg-hover); }
.ie-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 190px;
    background: var(--ie-bg-card);
    border: 1px solid var(--ie-border);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    padding: 0.35rem;
    z-index: 30;
    display: none;
}
.ie-dropdown.is-visible { display: block; }
.ie-dropdown button {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--ie-text);
}
.ie-dropdown button:hover { background: var(--ie-bg-soft); }
.ie-contextbar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.65rem;
    border-bottom: 1px solid var(--ie-border);
    background: linear-gradient(180deg, var(--ie-bg-main) 0%, var(--ie-bg-soft) 100%);
    overflow-x: auto;
}
.ie-cb-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding-right: 0.55rem;
    margin-right: 0.2rem;
    border-right: 1px solid var(--ie-border-strong);
    white-space: nowrap;
}
.ie-cb-group:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.ie-cb-label {
    font-size: 0.75rem;
    color: var(--ie-text-muted);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.ie-cb-input,
.ie-cb-select {
    border: 1px solid var(--ie-border-strong);
    border-radius: 6px;
    background: var(--ie-bg-control);
    color: var(--ie-text);
    height: 28px;
    padding: 0 0.45rem;
    font-size: 0.79rem;
    min-width: 58px;
}
.ie-cb-iconbtn {
    border: 1px solid var(--ie-border-strong);
    border-radius: 6px;
    background: var(--ie-bg-control);
    color: var(--ie-text-muted);
    font-size: 0.77rem;
    height: 28px;
    min-width: 28px;
    padding: 0 0.35rem;
    font-weight: 700;
}
.ie-cb-actionbtn {
    border: 1px solid var(--ie-border-strong);
    border-radius: 6px;
    background: var(--ie-bg-control);
    color: var(--ie-text);
    font-size: 0.77rem;
    height: 28px;
    padding: 0 0.45rem;
    font-weight: 700;
    cursor: pointer;
}
.ie-cb-actionbtn:hover { background: var(--ie-bg-hover); }
.ie-cb-kind-btn {
    border: 1px solid var(--ie-border-strong);
    border-radius: 5px;
    background: var(--ie-bg-control);
    color: var(--ie-text);
    font-size: 0.72rem;
    height: 26px;
    padding: 0 0.4rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.ie-cb-kind-btn:hover { background: var(--ie-bg-hover); }
.ie-cb-kind-btn.is-active {
    border-color: var(--ie-accent);
    background: var(--ie-bg-active);
    color: var(--ie-accent);
}
.ie-cb-iconbtn.is-active {
    border-color: var(--ie-accent);
    background: var(--ie-bg-active);
    color: var(--ie-text);
}
.ie-workspace {
    display: grid;
    grid-template-columns: 330px 1fr 320px;
    min-height: calc(100vh - 180px);
}
.ie-workspace > * {
    min-width: 0;
}
.ie-left,
.ie-right {
    background: var(--ie-bg-main);
    padding: 1rem 0.9rem;
}
.ie-left { border-right: 1px solid var(--ie-border-muted); padding: 0; }
.ie-right {
    border-left: 1px solid var(--ie-border-muted);
    padding: 0.7rem 0.7rem 0.8rem;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 0.55rem;
}
.ie-canvas {
    min-width: 0;
    padding: 0.35rem;
    background:
        linear-gradient(45deg, var(--ie-bg-canvas-a) 25%, transparent 25%) 0 0/18px 18px,
        linear-gradient(-45deg, var(--ie-bg-canvas-a) 25%, transparent 25%) 0 9px/18px 18px,
        linear-gradient(45deg, transparent 75%, var(--ie-bg-canvas-a) 75%) 9px -9px/18px 18px,
        linear-gradient(-45deg, transparent 75%, var(--ie-bg-canvas-a) 75%) -9px 0/18px 18px;
}
.ie-canvas-box {
    height: 100%;
    min-height: calc(100vh - 260px);
    border: 1px dashed var(--ie-border-strong);
    border-radius: 8px;
    background: color-mix(in srgb, var(--ie-bg-canvas-b) 88%, transparent);
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--ie-text-muted);
    font-size: 0.94rem;
    padding: 1rem;
}
.ie-canvas-box.is-document {
    display: block;
    overflow: auto;
    padding: 0.6rem;
}
.ie-stage {
    position: relative;
    display: inline-block;
    line-height: 0;
    border: 1px solid var(--ie-border);
    border-radius: 6px;
    background: var(--ie-bg-canvas-b);
}
.ie-stage-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
}
.ie-stage-layer.base {
    position: relative;
    display: block;
}
.ie-selection-box {
    position: absolute;
    border: 1px solid var(--ie-accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ie-accent) 40%, transparent);
    pointer-events: auto;
}
.ie-selection-box.locked {
    border-style: dashed;
    opacity: 0.75;
}
.ie-selection-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--ie-accent);
    border: 1px solid #fff;
    border-radius: 2px;
}
.ie-selection-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.ie-selection-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.ie-selection-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.ie-selection-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.ie-rotation-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border: 2px solid var(--ie-accent);
    border-radius: 50%;
    left: 50%;
    top: -28px;
    transform: translateX(-50%);
    cursor: crosshair;
    z-index: 2;
}
.ie-rotation-handle::after {
    content: '';
    position: absolute;
    width: 1px;
    height: 18px;
    background: var(--ie-accent);
    left: calc(50% - 0.5px);
    top: 100%;
}
.ie-preview {
    max-width: 100%;
    max-height: calc(100vh - 240px);
    border: 1px solid var(--ie-border);
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    background: var(--ie-bg-canvas-b);
}
.ie-status { margin-top: 0.4rem; font-size: 0.86rem; color: var(--ie-text-muted); }
.ie-status.error { color: var(--ie-danger); }
.ie-left-split {
    display: grid;
    grid-template-columns: 58px 1fr;
    min-height: 100%;
}
.ie-tool-rail {
    background: var(--ie-bg-rail);
    border-right: 1px solid var(--ie-border);
    padding: 0.45rem 0.22rem;
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    overflow-y: auto;
}
.ie-tool-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--ie-border-strong);
    border-radius: 6px;
    background: var(--ie-bg-control);
    display: grid;
    place-items: center;
    cursor: help;
    padding: 0;
    margin: 0 auto;
}
.ie-tool-btn:hover { background: var(--ie-bg-main); border-color: #94a3b8; }
.ie-tool-btn.is-active {
    border-color: var(--ie-accent);
    box-shadow: inset 0 0 0 1px var(--ie-accent);
    background: var(--ie-bg-active);
}
.ie-tool-btn img { width: 21px; height: 21px; object-fit: contain; }
.ie-tab-pane { padding: 0.8rem 0.75rem; display: flex; flex-direction: column; gap: 0.65rem; }
.ie-tabs { display: flex; gap: 0.35rem; border-bottom: 1px solid var(--ie-border-muted); padding-bottom: 0.45rem; }
.ie-tab-btn,
.ie-mini-tab,
.ie-ghost-btn,
.ie-small-btn,
.ie-file-btn,
.ie-input-sm,
.ie-field input,
.ie-field select,
.ie-btn.cancel {
    border: 1px solid var(--ie-border-strong);
    background: var(--ie-bg-control);
    color: var(--ie-text-muted);
}
.ie-tab-btn {
    border-radius: 6px;
    padding: 0.32rem 0.55rem;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
}
.ie-tab-btn.is-active,
.ie-mini-tab.is-active,
.ie-layer-item.is-active {
    color: var(--ie-text);
    border-color: var(--ie-accent);
    background: var(--ie-bg-active);
}
.ie-tab-body,
.ie-right-card,
.ie-bottom-utilities,
.ie-layer-item,
.ie-modal-card { border: 1px solid var(--ie-border); border-radius: 8px; background: var(--ie-bg-card); }
.ie-tab-body { padding: 0.65rem; min-height: 180px; }
.ie-tool-title { margin: 0 0 0.45rem; font-size: 0.9rem; color: var(--ie-text); }
.ie-placeholder-copy,
.ie-note,
.ie-dropzone p,
.ie-modal-status,
.ie-selected,
.ie-field label,
.ie-slider-row label,
.ie-layer-item,
.ie-list,
.ie-close,
.ie-input-sm,
.ie-field input,
.ie-inline,
.ie-cb-iconbtn,
.ie-mini-tab,
.ie-ghost-btn,
.ie-small-btn,
.ie-file-btn { color: var(--ie-text-muted); }
.ie-right-title { margin: 0 0 0.5rem; font-size: 0.8rem; color: var(--ie-text); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.ie-mini-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.5rem; }
.ie-mini-tab { border-radius: 6px; padding: 0.25rem 0.45rem; font-size: 0.74rem; cursor: default; font-weight: 600; }
.ie-color-row { display: grid; grid-template-columns: 32px 1fr; gap: 0.45rem; align-items: center; margin-bottom: 0.45rem; }
.ie-color-chip { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ie-border-strong); background: #ff5533; }
.ie-input-sm { width: 100%; border-radius: 6px; padding: 0.35rem 0.45rem; font-size: 0.8rem; }
.ie-slider-row { margin-top: 0.35rem; }
.ie-slider-row label { display: flex; justify-content: space-between; font-size: 0.76rem; margin-bottom: 0.2rem; }
.ie-slider-row input[type="range"] { width: 100%; }
.ie-layers { min-height: 260px; display: grid; grid-template-rows: auto 1fr auto; gap: 0.5rem; }
.ie-layer-list {
    border: 1px solid var(--ie-border);
    border-radius: 6px;
    background: var(--ie-bg-main);
    padding: 0.3rem;
    overflow-y: auto;
    min-height: 180px;
    max-height: 40vh;
}
.ie-layer-item { border-radius: 6px; padding: 0.35rem 0.4rem; font-size: 0.78rem; margin-bottom: 0.3rem; display: flex; justify-content: space-between; align-items: center; }
.ie-layer-empty {
    font-size: 0.78rem;
    color: var(--ie-text-soft);
    padding: 0.35rem 0.4rem;
}
.ie-layer-item {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 0.35rem;
    align-items: center;
}
.ie-layer-thumb {
    width: 26px;
    height: 26px;
    border: 1px solid var(--ie-border-strong);
    border-radius: 4px;
    background: var(--ie-bg-control);
    object-fit: cover;
}
.ie-layer-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ie-layer-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ie-layer-sub {
    font-size: 0.68rem;
    color: var(--ie-text-soft);
}
.ie-layer-icon-btn {
    border: 1px solid var(--ie-border-strong);
    background: var(--ie-bg-control);
    color: var(--ie-text-muted);
    border-radius: 4px;
    width: 22px;
    height: 22px;
    line-height: 1;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
}
.ie-layer-icon-btn.off {
    opacity: 0.5;
}
.ie-layer-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
.ie-ghost-btn { border-radius: 6px; padding: 0.34rem 0.45rem; font-size: 0.75rem; font-weight: 600; }
.ie-ghost-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.ie-bottom-utilities { padding: 0.5rem 0.6rem; }
.ie-bottom-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.35rem; }
.ie-note { width: 100%; margin: 0 auto 0.5rem; font-size: 0.9rem; }
.ie-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.58);
    z-index: 100;
    padding: 1rem;
}
.ie-modal.is-visible { display: flex; }
.ie-modal-card {
    width: min(92vw, 680px);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}
.ie-modal-head {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--ie-border-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ie-modal-head h3 { margin: 0; font-size: 1rem; color: var(--ie-text); }
.ie-close { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; line-height: 1; }
.ie-modal-body { padding: 1rem; }
.ie-limit-note {
    border: 1px solid var(--ie-border);
    border-radius: 8px;
    background: var(--ie-bg-soft);
    color: var(--ie-text);
    font-size: 0.82rem;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.75rem;
}
.ie-dropzone {
    border: 2px dashed #93c5fd;
    border-radius: 10px;
    background: color-mix(in srgb, var(--ie-bg-active) 65%, var(--ie-bg-card));
    padding: 1rem;
    text-align: center;
}
.ie-dropzone.drag-over { border-color: var(--ie-accent); background: var(--ie-bg-active); }
.ie-file-btn { margin-top: 0.5rem; padding: 0.45rem 0.7rem; border-radius: 6px; cursor: pointer; }
.ie-modal-actions { margin-top: 0.9rem; display: flex; justify-content: flex-end; gap: 0.5rem; }
.ie-btn { border: 0; border-radius: 6px; padding: 0.5rem 0.85rem; cursor: pointer; font-weight: 600; }
.ie-btn.primary { background: var(--ie-accent); color: #fff; }
.ie-btn.primary:disabled { background: #93c5fd; cursor: not-allowed; }
.ie-selected { margin-top: 0.7rem; font-size: 0.86rem; word-break: break-all; }
.ie-hint { margin-top: 0.6rem; font-size: 0.78rem; color: var(--ie-text-soft); }
.ie-warning-text { color: #dc2626; font-weight: 600; }
.ie-modal-status { margin-top: 0.6rem; font-size: 0.84rem; min-height: 1.1rem; }
.ie-modal-status.error { color: var(--ie-danger); }
.ie-parser-wrap {
    border: 1px solid var(--ie-border);
    border-radius: 8px;
    overflow: auto;
    max-height: min(65vh, 620px);
    background: var(--ie-bg-main);
    padding: 0.5rem;
}
.ie-parser-stage { position: relative; display: inline-block; line-height: 0; cursor: crosshair; }
.ie-parser-stage img { display: block; max-width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.ie-parser-selection {
    position: absolute;
    border: 2px solid var(--ie-accent);
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.35);
    display: none;
    cursor: move;
}
.ie-parser-handle {
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: var(--ie-accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.6);
    pointer-events: auto;
}
.ie-parser-handle.nw { top: -7px; left: -7px; cursor: nwse-resize; }
.ie-parser-handle.ne { top: -7px; right: -7px; cursor: nesw-resize; }
.ie-parser-handle.sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.ie-parser-handle.se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.ie-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.8rem; align-items: end; }
.ie-field label { display: block; font-size: 0.8rem; margin-bottom: 0.3rem; }
.ie-field input { width: 100%; border-radius: 6px; padding: 0.45rem 0.55rem; font-size: 0.9rem; }
.ie-field select { width: 100%; border-radius: 6px; padding: 0.45rem 0.55rem; font-size: 0.9rem; border: 1px solid var(--ie-border-strong); background: var(--ie-bg-control); color: var(--ie-text); }
.ie-grid-3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0.6rem; margin-top: 0.6rem; align-items: end; }
.ie-inline { display: flex; align-items: center; gap: 0.45rem; min-height: 38px; }
.ie-color-swatch {
    width: 28px;
    height: 28px;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    background: var(--ie-bg-card);
    flex: 0 0 auto;
}
.ie-small-btn { border-radius: 6px; padding: 0.4rem 0.58rem; font-size: 0.8rem; cursor: pointer; }
.ie-size-results {
    margin-top: 0.7rem;
    border: 1px solid var(--ie-border);
    border-radius: 8px;
    background: var(--ie-bg-card);
    max-height: min(45vh, 380px);
    overflow: auto;
}
.ie-size-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.ie-size-table th,
.ie-size-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid var(--ie-border-muted);
    text-align: left;
    color: var(--ie-text-muted);
    white-space: nowrap;
}
.ie-size-table th {
    position: sticky;
    top: 0;
    background: var(--ie-bg-soft);
    color: var(--ie-text);
    z-index: 1;
}
.ie-size-table td:first-child,
.ie-size-table th:first-child {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Context bar slots ─────────────────────────────────────────────────── */
.ie-cb-slot {
    display: contents; /* slot groups flow inline with the bar */
}
.ie-cb-slot[hidden] {
    display: none;
}
.ie-cb-subgroup[hidden] {
    display: none;
}
.ie-cb-tool-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ie-text);
    white-space: nowrap;
    min-width: 80px;
}
.ie-cb-swatch {
    width: 22px;
    height: 22px;
    border: 2px solid var(--ie-border-strong);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    flex: 0 0 auto;
}
.ie-cb-swatch:hover {
    border-color: var(--ie-accent);
}
.ie-cb-color-hex {
    width: 68px;
    font-family: monospace;
    font-size: 0.78rem;
    text-transform: uppercase;
}
.ie-cb-range {
    width: 80px;
    cursor: pointer;
}
.ie-cb-value {
    font-size: 0.75rem;
    color: var(--ie-text-muted);
    white-space: nowrap;
    min-width: 32px;
}
.ie-cb-check {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--ie-text-muted);
    cursor: pointer;
    white-space: nowrap;
}

/* ── Shape draw overlay ────────────────────────────────────────────────── */
.ie-shape-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* Crosshair cursor while shapes tool is active */
.ie-stage.ie-shapes-active {
    cursor: crosshair;
}

/* Text cursor while text tool is active */
.ie-canvas-box.ie-text-active,
.ie-canvas-box.ie-text-active .ie-stage {
    cursor: text;
}

/* ── Text context bar font select ───────────────────────────────────────── */
.ie-cb-select {
    height: 28px;
    border: 1px solid var(--ie-border-strong);
    background: var(--ie-bg-control);
    color: var(--ie-text);
    border-radius: 5px;
    font-size: 0.82rem;
    padding: 0 0.35rem;
    max-width: 170px;
    cursor: pointer;
}
.ie-cb-select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* ── Floating text-entry popup ──────────────────────────────────────────── */
.ie-text-popup {
    position: fixed;
    width: 268px;
    background: var(--ie-bg-card);
    border: 1px solid var(--ie-border-strong);
    border-radius: 8px;
    padding: 0.7rem;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
    z-index: 1200;
}
.ie-text-popup-area {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 72px;
    resize: vertical;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid var(--ie-border-strong);
    background: var(--ie-bg-control);
    color: var(--ie-text);
    border-radius: 5px;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.5rem;
    outline: none;
}
.ie-text-popup-area:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22);
}
.ie-text-popup-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
}

/* ── Image Parser: near full-screen workspace ──────────────────────────── */
#ieParserModal {
    padding: 0.6rem;
}
#ieParserModal .ie-modal-card {
    width: min(98vw, 1780px);
    height: 94vh;
    max-height: 94vh;
    display: grid;
    grid-template-rows: auto 1fr;
}
#ieParserModal .ie-modal-body {
    height: 100%;
    overflow: auto;
}
#ieParserModal .ie-parser-wrap {
    max-height: min(78vh, 1400px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --ie-bg-main: #141a22;
        --ie-bg-shell: #1a2230;
        --ie-bg-soft: #202c3d;
        --ie-bg-rail: #101722;
        --ie-bg-card: #1c2635;
        --ie-bg-control: #222e40;
        --ie-bg-hover: #2c3a50;
        --ie-bg-active: #173454;
        --ie-bg-canvas-a: #223146;
        --ie-bg-canvas-b: #101722;
        --ie-border: #334155;
        --ie-border-strong: #475569;
        --ie-border-muted: #3a4a63;
        --ie-text: #e2e8f0;
        --ie-text-muted: #cbd5e1;
        --ie-text-soft: #94a3b8;
        --ie-danger: #f87171;
    }
    .ie-modal { background: rgba(2, 6, 23, 0.72); }
    .ie-parser-selection { box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.62); }
}

:root[data-ie-theme="light"] {
    --ie-bg-main: #f8fafc;
    --ie-bg-shell: #ffffff;
    --ie-bg-soft: #f1f5f9;
    --ie-bg-rail: #edf2f7;
    --ie-bg-card: #ffffff;
    --ie-bg-control: #ffffff;
    --ie-bg-hover: #e2e8f0;
    --ie-bg-active: #eff6ff;
    --ie-bg-canvas-a: #f1f5f9;
    --ie-bg-canvas-b: #ffffff;
    --ie-border: #dbe2ea;
    --ie-border-strong: #cbd5e1;
    --ie-border-muted: #e6ecf2;
    --ie-text: #0f172a;
    --ie-text-muted: #475569;
    --ie-text-soft: #64748b;
    --ie-accent: #2563eb;
    --ie-danger: #b91c1c;
}

:root[data-ie-theme="dark"] {
    --ie-bg-main: #141a22;
    --ie-bg-shell: #1a2230;
    --ie-bg-soft: #202c3d;
    --ie-bg-rail: #101722;
    --ie-bg-card: #1c2635;
    --ie-bg-control: #222e40;
    --ie-bg-hover: #2c3a50;
    --ie-bg-active: #173454;
    --ie-bg-canvas-a: #223146;
    --ie-bg-canvas-b: #101722;
    --ie-border: #334155;
    --ie-border-strong: #475569;
    --ie-border-muted: #3a4a63;
    --ie-text: #e2e8f0;
    --ie-text-muted: #cbd5e1;
    --ie-text-soft: #94a3b8;
    --ie-danger: #f87171;
}

@media (max-width: 1080px) {
    .ie-workspace { grid-template-columns: 300px 1fr; }
    .ie-right { grid-column: 1 / span 2; border-left: 0; border-top: 1px solid var(--ie-border-muted); }
}
@media (max-width: 760px) {
    .ie-workspace { grid-template-columns: 1fr; }
    .ie-left,
    .ie-right { border: 0; border-top: 1px solid var(--ie-border-muted); }
    .ie-left-split { grid-template-columns: 56px 1fr; }
    .ie-tool-btn { width: 36px; height: 36px; }
    .ie-left { order: 2; }
    .ie-canvas { order: 1; }
    .ie-right { order: 3; }
}
