:root {
    --accent: #4a7fd4;
    --accent-focus: #4a90e2;
    --accent-strong: #2459a6;
    --action-danger: #e74c3c;
    --action-danger-hover: #c0392b;
    --action-success-active: #2d4b11;
    --action-success-border: #355814;
    --action-success-hover: #355814;
    --action-success: #40661a;
    --bg-active: #e8e8f0;
    --bg-canvas: #f0f0f0;
    --bg-deep: #eee;
    --bg-error-muted: #fef2f2;
    --bg-hover-alt: #eef;
    --bg-hover-muted: #f5f5fa;
    --bg-hover: #f0f0f8;
    --bg-primary: #f5f5f5;
    --bg-success-muted: #f0fdf4;
    --bg-surface-alt: #fafafa;
    --bg-surface-cool: #f8f8fc;
    --bg-surface-dim: #f2f2f2;
    --bg-surface-info: #f0f4ff;
    --bg-surface: white;
    --bg-warning-muted: #fffbeb;
    --border-active: #6b7280;
    --border-hover: #b6becb;
    --border-input: #e0e0e0;
    --border-soft: #d8dde6;
    --border: #d8dde3;
    --control-bg-hover: #f3f6fb;
    --control-shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.10);
    --control-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
    --radius-lg: 8px;
    --radius-md: 6px;
    --radius-pill: 999px;
    --radius-sm: 4px;
    --radius-xl: 12px;
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.2);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.15);
    --text-dim: #515760;
    --text-disabled: #7b818a;
    --text-hover: #2f3640;
    --text-icon: #616875;
    --text-label: #414853;
    --text-light: #7b818a;
    --text-meta: #616875;
    --text-mid: #4f5660;
    --text-muted-alt: #616875;
    --text-muted: #59616d;
    --text-placeholder: #6b7280;
    --text-primary: #333;
    --text-secondary: #444;
    --text-soft: #4a515b;
    --text-subtle: #6b7280;
    --text-very-dim: #6a717d;
    --text-white-kw: #333;
    --text-white: #333;
    --transition-default: 150ms;
    --transition-fast: 120ms;
    --warning: #d4a020;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: 'Avenir Next', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-white-kw);
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    align-items: center;
    min-height: 64px;
    padding: 12px 16px;
    gap: 14px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.header-left {
    flex-shrink: 0;
}

header h1 {
    font-size: 17px;
    font-weight: 650;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.header-center {
    flex: 1;
    min-width: 0;
}

.flow-name {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    max-width: 100%;
    padding: 0 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    background: var(--bg-surface-alt);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.header-primary-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.header-overflow {
    position: relative;
    flex-shrink: 0;
}

.header-overflow-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(280px, calc(100vw - 32px));
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--bg-surface);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
    display: grid;
    gap: 4px;
    z-index: 220;
}

.header-overflow-menu[hidden] {
    display: none;
}

.flow-btn-menu {
    width: 100%;
    justify-content: flex-start;
    box-shadow: none;
}

.flow-btn-menu.hidden {
    display: none;
}

.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}


.toolbox {
    width: 210px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 10px;
}

.toolbox-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    min-height: 36px;
    touch-action: manipulation;
}

.toolbox-toggle:active {
    background: var(--bg-hover);
}

.toolbox-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.toolbox-collapsed + .toolbox-toggle svg,
.toolbox-toggle.collapsed svg {
    transform: rotate(180deg);
}

.toolbox-search {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 12px;
    box-sizing: border-box;
    outline: none;
    color: var(--text-hover);
    background: var(--bg-surface);
}

.toolbox-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 127, 212, 0.14);
}

.tool-group {
    margin-bottom: 4px;
}

.tool-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 10px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-soft);
    border-left: 3px solid #c3cad5;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-default);
    user-select: none;
}

.tool-group-header:hover {
    background: var(--bg-canvas);
}

.tool-group-header:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 2px;
}

.group-icon {
    font-size: 8px;
    color: var(--text-subtle);
    width: 10px;
    text-align: center;
}

.group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.tool-group-items {
    margin-top: 4px;
    margin-bottom: 4px;
}

.tool-group-items.collapsed {
    display: none;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 10px;
    margin-bottom: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    cursor: grab;
    transition: all var(--transition-default);
}

.tool-item:hover {
    background: var(--control-bg-hover);
    border-color: var(--border-hover);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.tool-item:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 1px;
}

.tool-item:active {
    cursor: grabbing;
}

.tool-item .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-hover);
}

.tool-item .icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.tool-item span:last-child {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}


.canvas {
    flex: 1;
    position: relative;
    overflow: auto;
    padding: 30px;
    cursor: default;
    user-select: none;
    contain: layout style;
    --canvas-width: 100%;
    --canvas-height: 100%;
}

.canvas::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: var(--canvas-width, 100%);
    height: var(--canvas-height, 100%);
    pointer-events: none;
    z-index: -1;
}

#canvas-inner {
    transform-origin: 0 0;
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

.canvas.panning {
    cursor: grabbing;
}

#connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-very-dim);
    font-size: 14px;
    text-align: center;
}


.block {
    position: absolute;
    width: 48px;
    cursor: move;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    contain: layout style;
}

.block:hover .block-icon-area {
    box-shadow: 0 3px 12px rgba(0,0,0,0.2);
    transform: scale(1.05);
}

.block.selected .block-icon-area {
    box-shadow: 0 0 0 3px rgba(74,144,226,0.5), 0 2px 8px rgba(0,0,0,0.15);
}

.block:focus-visible .block-icon-area,
.block:focus-within .block-icon-area {
    box-shadow: 0 0 0 3px rgba(46,110,196,0.55), 0 2px 10px rgba(0,0,0,0.2);
}

.block.needs-input .block-icon-area {
    outline: 2px dashed #e0a030;
    outline-offset: 2px;
}

.block.disabled {
    opacity: 0.4;
}

.block.disabled .block-label {
    text-decoration: line-through;
}


.block-icon-area {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--block-color, #999);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: box-shadow var(--transition-default), transform var(--transition-default);
}

.block-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-surface);
}

.block-icon svg {
    width: 24px;
    height: 24px;
    display: block;
    stroke: var(--bg-surface);
}


.block-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-hover);
    margin-top: 4px;
    text-align: center;
    white-space: nowrap;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}


.block-actions {
    display: none;
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    padding: 4px;
    gap: 4px;
    z-index: 20;
    white-space: nowrap;
    align-items: center;
}

.block:hover .block-actions,
.block:focus-within .block-actions,
.block.selected .block-actions,
.block.multi-selected .block-actions {
    display: none;
}

.block-action-btn {
    appearance: none;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    min-width: 30px;
    min-height: 30px;
    padding: 7px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font: inherit;
    line-height: 1;
    touch-action: manipulation;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.block-action-btn svg {
    width: 14px;
    height: 14px;
    display: block;
}

.block-action-btn:hover,
.block-action-btn:focus-visible {
    background: var(--bg-canvas);
    color: var(--text-white-kw);
}

.block-action-btn:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 1px;
}

.block-action-btn:disabled {
    cursor: not-allowed;
    color: var(--text-disabled);
    opacity: 0.48;
}

.block-action-btn:disabled:hover {
    background: transparent;
    color: var(--text-disabled);
}

.block-data-in:not(:disabled):hover {
    background: #e8f5e9;
    color: #388e3c;
}


.block-data-out:not(:disabled):hover {
    background: #e3f2fd;
    color: #1976d2;
}


.block-metadata:hover {
    background: #f3e5f5;
    color: #7b1fa2;
}


.block-disable {
    font-size: 10px;
}

.block-disable:not(:disabled):hover {
    background: #fff3e0;
    color: #e65100;
}


.block-delete {
    font-size: 13px;
}

.block-delete:not(:disabled):hover {
    background: #fee;
    color: #e44;
}


.block-content,
.block-status {
    display: none;
}


.block-badge {
    font-size: 9px;
    color: var(--text-muted-alt);
    margin-top: 1px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

.block-badge:empty {
    display: none;
}


.block-connector {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--bg-surface);
    border: 2px solid var(--accent-focus);
    border-radius: 50%;
    cursor: crosshair;
    transition: all var(--transition-default) ease;
    z-index: 10;
}

.block-connector:hover {
    background: #e3f2fd;
    transform: scale(1.3);
    box-shadow: 0 0 6px rgba(74, 144, 226, 0.4);
}

.block-connector.active {
    background: var(--accent-focus);
    border-color: #2171d4;
    transform: scale(1.4);
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.6);
    animation: pulse 1s infinite;
}

.block-connector.target {
    background: #66bb6a;
    border-color: #43a047;
    transform: scale(1.4);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.6);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(74, 144, 226, 0.6);
    }
    50% {
        box-shadow: 0 0 18px rgba(74, 144, 226, 0.9);
    }
}

.connector-out {
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
}

.connector-out:hover,
.connector-out.active {
    transform: translateY(-50%) scale(1.3);
}


.connector-anchor {
    width: 16px;
    height: 16px;
    right: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.anchor-label {
    font-size: 8px;
    font-weight: 700;
    color: var(--bg-surface);
    pointer-events: none;
    line-height: 1;
}

.connector-in {
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
}

.connector-in:hover,
.connector-in.target {
    transform: translateY(-50%) scale(1.3);
}


.connection-line {
    position: absolute;
    stroke: #2b9cff;
    stroke-width: 2;
    fill: none;
    pointer-events: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-opacity: 0.4;
    transition: stroke-opacity var(--transition-fast) ease, stroke-width var(--transition-fast) ease;
}

.connection-line.active {
    stroke-opacity: 1;
    stroke-width: 3;
}

.connection-line.selected {
    stroke: #e0a030;
    stroke-opacity: 1;
    stroke-width: 3;
    stroke-dasharray: 6 3;
}

.connection-hit-area {
    stroke: transparent;
    stroke-width: 14;
    fill: none;
    pointer-events: stroke;
    cursor: pointer;
}

.connection-label {
    font-size: 10px;
    fill: var(--text-dim);
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.connection-label-bg {
    fill: var(--bg-surface);
    fill-opacity: 0.9;
    pointer-events: none;
}

.temp-connection-line {
    position: absolute;
    stroke: var(--accent-focus);
    stroke-width: 2;
    fill: none;
    pointer-events: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.5;
    stroke-dasharray: 5, 5;
}


.zoom-controls-float {
    position: fixed;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 100;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: var(--control-shadow);
    transition: right 0.2s ease;
}

.flow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-surface);
    box-shadow: var(--control-shadow);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-hover);
    transition: all var(--transition-default);
    font-family: inherit;
    touch-action: manipulation;
}

.flow-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.flow-btn:hover {
    background: var(--control-bg-hover);
    border-color: var(--border-hover);
    box-shadow: var(--control-shadow-hover);
    color: var(--text-white-kw);
}

.flow-btn:active {
    background: var(--bg-canvas);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.flow-btn:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 2px;
}


.canvas-run-btn {
    position: fixed;
    top: 76px;
    right: 12px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.run-btn {
    background: var(--action-success);
    color: var(--bg-surface);
    border-color: var(--action-success-border);
    font-weight: 600;
}
.run-btn:hover {
    background: var(--action-success-hover);
    color: var(--bg-surface);
    border-color: var(--action-success-hover);
}
.run-btn:active {
    background: var(--action-success-active);
}
.run-btn svg { width: 12px; height: 12px; }
.run-btn.running { animation: pulse-run 0.6s ease-in-out; }
@keyframes pulse-run {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); box-shadow: 0 0 12px rgba(104,162,37,0.5); }
    100% { transform: scale(1); }
}


.preview-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 2px solid #eee;
}

.preview-tab {
    padding: 6px 16px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted-alt);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-default);
    font-family: inherit;
}

.preview-tab:hover {
    color: var(--text-hover);
}

.preview-tab.active {
    color: #2e6ec4;
    border-bottom-color: #2e6ec4;
}

.profile-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.profile-table th {
    background: var(--bg-primary);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-hover);
    border-bottom: 2px solid var(--border-input);
    white-space: nowrap;
}

.profile-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.profile-table tr:hover td {
    background: var(--bg-surface-alt);
}

.profile-col-name {
    font-weight: 600;
    color: var(--text-white-kw);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-type {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

.profile-type-string { background: #e3f2fd; color: #1565c0; }
.profile-type-number { background: #e8f5e9; color: #2e7d32; }
.profile-type-date { background: #fff3e0; color: #e65100; }
.profile-type-boolean { background: #f3e5f5; color: #7b1fa2; }

.profile-top-values {
    color: var(--text-muted);
    font-size: 11px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-summary {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted-alt);
}


.hint-link,
.template-gallery-close,
.config-panel-close,
.close {
    appearance: none;
    border: none;
    background: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    line-height: 1;
    touch-action: manipulation;
}

.hint-link {
    color: #2e6ec4;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-size: 13px;
    padding: 0;
}

.hint-link:hover {
    color: #1a4f8a;
}

.hint-link:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 2px;
    border-radius: 3px;
}


.template-gallery-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-gallery {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 820px;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.template-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.template-gallery-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white-kw);
}

.template-gallery-close {
    cursor: pointer;
    font-size: 22px;
    color: var(--text-subtle);
    min-width: 32px;
    min-height: 32px;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-default);
}

.template-gallery-close:hover {
    background: var(--bg-canvas);
    color: var(--text-white-kw);
}

.template-gallery-close:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 2px;
}

.template-gallery-grid {
    padding: 16px 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.template-gallery-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 0;
}

.template-gallery-search {
    flex: 1;
    min-width: 180px;
    border: 1px solid #d8d8d8;
    border-radius: var(--radius-lg);
    padding: 9px 12px;
    font-size: 13px;
}

.template-gallery-search:focus {
    outline: none;
    border-color: #2e6ec4;
    box-shadow: 0 0 0 2px rgba(46, 110, 196, 0.15);
}

.template-gallery-count {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}

.template-card {
    border: 1px solid #e5e5e5;
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    cursor: pointer;
    transition: all var(--transition-default);
}

.template-card:hover {
    border-color: #2e6ec4;
    background: #f8fbff;
    box-shadow: 0 2px 8px rgba(46,110,196,0.12);
}

.template-card:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 2px;
}

.template-card-preview {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.template-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid #e5e5e5;
}

.template-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-white-kw);
    margin-bottom: 2px;
}

.template-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.template-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

.template-card-category {
    font-size: 11px;
    font-weight: 600;
    color: #2e6ec4;
    background: #edf4ff;
    border-radius: var(--radius-pill);
    padding: 3px 8px;
}

.template-card-count {
    font-size: 11px;
    color: var(--text-dim);
}

.template-gallery-empty {
    grid-column: 1 / -1;
    border: 1px dashed #d7d7d7;
    border-radius: var(--radius-lg);
    padding: 16px;
    color: var(--text-dim);
    font-size: 13px;
    text-align: center;
}


.tool-container {
    position: absolute;
    border: 2px dashed rgba(100, 100, 200, 0.4);
    border-radius: var(--radius-lg);
    background: rgba(100, 100, 200, 0.04);
    z-index: 0;
    pointer-events: none;
}

.tool-container-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px 6px 0 0;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    pointer-events: auto;
    cursor: move;
    user-select: none;
}

.tool-container-toggle {
    cursor: pointer;
    font-size: 10px;
    opacity: 0.8;
}

.tool-container-label {
    flex: 1;
    outline: none;
    cursor: text;
    min-width: 40px;
}

.tool-container-label:focus {
    cursor: text;
    border-bottom: 1px solid rgba(255,255,255,0.5);
}

.tool-container-delete {
    cursor: pointer;
    opacity: 0;
    font-size: 14px;
    transition: opacity var(--transition-default);
}

.tool-container-title:hover .tool-container-delete {
    opacity: 0.7;
}

.tool-container-delete:hover {
    opacity: 1 !important;
}

.tool-container.collapsed {
    height: auto !important;
    min-height: 0;
    border-style: solid;
    background: none;
}


.annotation {
    position: absolute;
    background: #fff9c4;
    border: 1px solid #e6d54d;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    min-width: 120px;
    min-height: 60px;
    z-index: 5;
    font-size: 12px;
    display: flex;
    flex-direction: column;
}

.annotation.dragging {
    opacity: 0.8;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.annotation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    border-bottom: 1px solid #e6d54d;
    background: #fff3a0;
    border-radius: 3px 3px 0 0;
    flex-shrink: 0;
}

.annotation-drag-handle {
    cursor: grab;
    color: var(--text-subtle);
    font-size: 11px;
    user-select: none;
}

.annotation-drag-handle:active {
    cursor: grabbing;
}

.annotation-delete {
    cursor: pointer;
    color: var(--text-very-dim);
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    border-radius: 3px;
    transition: all var(--transition-default);
}

.annotation-delete:hover {
    color: #c00;
    background: rgba(200,0,0,0.1);
}

.annotation-body {
    padding: 6px 8px;
    outline: none;
    color: var(--text-hover);
    line-height: 1.4;
    min-height: 36px;
    word-break: break-word;
    white-space: pre-wrap;
    resize: vertical;
    overflow: auto;
}

.annotation-body:empty::before {
    content: 'Type a note...';
    color: var(--text-very-dim);
    font-style: italic;
}

.annotation-body:focus {
    background: #fffde7;
}


.recent-flows-dropdown {
    position: fixed;
    z-index: 1000;
    background: var(--bg-surface);
    border: 1px solid #ddd;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    min-width: 280px;
    max-width: 360px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px 0;
}

.recent-flow-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.recent-flow-item:last-child {
    border-bottom: none;
}

.recent-flow-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 2px 0;
}

.recent-flow-info:hover .recent-flow-name {
    color: #2e6ec4;
}

.recent-flow-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-white-kw);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color var(--transition-default);
}

.recent-flow-meta {
    display: block;
    font-size: 11px;
    color: var(--text-muted-alt);
    margin-top: 2px;
}

.recent-flow-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--text-very-dim);
    font-size: 16px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-default);
}

.recent-flow-remove:hover {
    background: #fee;
    color: #c00;
}

.zoom-btn {
    min-width: 40px;
    padding: 0 10px;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.zoom-indicator {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    min-width: 36px;
    text-align: center;
}


.config-panel {
    width: 0;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
}

.config-panel.open {
    width: 400px;
}

.config-panel.open.wide {
    width: 540px;
}

.config-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-width: 400px;
}

.config-panel.wide .config-panel-header {
    min-width: 540px;
}

.config-panel-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-hover);
}

.config-panel-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.config-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-white-kw);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

.panel-actions .block-action-btn {
    min-width: unset;
    min-height: unset;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: var(--bg-canvas);
    border: 1px solid var(--border);
}

.panel-actions .block-action-btn svg {
    display: none;
}

.panel-actions .block-delete {
    font-size: 11px;
}

.config-panel-close {
    color: var(--text-subtle);
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    min-width: 28px;
    min-height: 28px;
    padding: 4px;
    flex-shrink: 0;
    margin-left: 4px;
}

.config-panel-close:hover {
    color: var(--text-white-kw);
}

.config-panel-close:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 2px;
    border-radius: 3px;
}

.config-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-width: 400px;
}

.config-panel.wide .config-panel-body {
    min-width: 540px;
}

.config-panel-footer {
    flex-shrink: 0;
    padding: 12px 16px;
    border-top: 1px solid var(--border-input);
    background: var(--bg-surface-alt);
    min-width: 400px;
}

.config-panel.wide .config-panel-footer {
    min-width: 540px;
}

.config-panel-footer:empty {
    display: none;
}


.config-data-divider {
    border: none;
    border-top: 1px solid #e8e8e8;
    margin: 12px 0 8px;
}

.config-data-section {
    margin-bottom: 6px;
}

.config-data-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-hover);
    padding: 5px 0;
    user-select: none;
}

.config-data-header:hover {
    color: var(--text-white-kw);
}

.config-data-chevron {
    font-size: 8px;
    color: var(--text-subtle);
    width: 10px;
    text-align: center;
}

.config-data-body {
    display: none;
    overflow: hidden;
}

.config-data-section.expanded .config-data-body {
    display: block;
}

.config-data-stats {
    font-size: 10px;
    color: var(--text-muted-alt);
    margin-bottom: 4px;
}

.config-data-empty {
    font-size: 11px;
    color: var(--text-disabled);
    font-style: italic;
    padding: 4px 0;
}

.config-data-table-wrap {
    max-height: 200px;
    overflow: auto;
    border: 1px solid #e8e8e8;
    border-radius: var(--radius-sm);
}

.config-data-table {
    width: 100%;
    font-size: 10px;
    border-collapse: collapse;
}

.config-data-table th {
    background: var(--bg-primary);
    font-weight: 600;
    text-align: left;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-input);
    position: sticky;
    top: 0;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.config-data-table td {
    padding: 3px 6px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-overflow: ellipsis;
}

.config-data-more {
    text-align: center;
    color: var(--text-disabled);
    font-style: italic;
}


.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
}

.modal.open {
    display: block;
}

.modal-content {
    background-color: var(--bg-surface);
    margin: 10% auto;
    padding: 30px;
    border-radius: var(--radius-lg);
    width: min(400px, 90vw);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-content.large {
    width: 80%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.modal-header {
    position: relative;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-input);
    flex-shrink: 0;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px 24px;
}

.modal-action-top {
    position: absolute;
    top: 16px;
    right: 50px;
    padding: 6px 14px;
    background: var(--accent-focus);
    color: var(--bg-surface);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background var(--transition-default);
}

.modal-action-top:hover {
    background: #357abd;
}

.close {
    color: var(--text-subtle);
    position: absolute;
    top: 16px;
    right: 18px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    min-width: 32px;
    min-height: 32px;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.close:hover {
    color: var(--text-white-kw);
}

.close:focus-visible {
    outline: 2px solid #2e6ec4;
    outline-offset: 2px;
    border-radius: 3px;
}

.modal h2 {
    font-size: 16px;
    margin-bottom: 0;
    font-weight: 600;
    padding-right: 100px;
}


.file-input-hidden {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    width: 1px;
    height: 1px;
    overflow: hidden;
    border: 0;
    padding: 0;
}

.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border: 1px solid #d0d0d0;
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 12px;
    transition: background var(--transition-default), border-color var(--transition-default);
}

.file-upload-btn:hover {
    background: #eaeaea;
    border-color: var(--text-very-dim);
}

.file-upload-btn svg {
    flex-shrink: 0;
}

#fileInfo {
    font-size: 13px;
    color: var(--text-dim);
}

.target-template-section {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
}

.target-template-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-hover);
    white-space: nowrap;
}

.target-template-btn {
    padding: 5px 10px;
    font-size: 11px;
}

.target-template-info {
    font-size: 12px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#dataDisplay {
    overflow-x: auto;
    max-height: 500px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

table th {
    background: #f8f8f8;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-input);
    position: sticky;
    top: 0;
    color: var(--text-hover);
}

table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
}

table tr:hover {
    background: var(--bg-surface-alt);
}


#applyAutomapper:hover {
    background: #3a7bc8;
}

#applyAutomapper:active {
    background: #2d6aa8;
}


.modal-description {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 15px;
}

.quick-add-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 320px;
}

.quick-add-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d8d8d8;
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
}

.quick-add-input:focus {
    border-color: var(--accent-focus);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.quick-add-hint {
    font-size: 12px;
    color: #6b6b6b;
}

.quick-add-list {
    border: 1px solid var(--border-input);
    border-radius: var(--radius-lg);
    overflow: auto;
    max-height: 360px;
}

.quick-add-item {
    width: 100%;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    cursor: pointer;
}

.quick-add-item:last-child {
    border-bottom: 0;
}

.quick-add-item:hover {
    background: #f5f8ff;
}

.quick-add-item.active {
    background: #eaf2ff;
    box-shadow: inset 3px 0 0 var(--accent-focus);
}

.quick-add-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-white-kw);
}

.quick-add-item-meta {
    font-size: 11px;
    color: #6f6f6f;
}

.quick-add-empty {
    padding: 14px;
    font-size: 13px;
    color: #6f6f6f;
}

.shortcut-help-intro {
    margin-bottom: 12px;
    font-size: 13px;
    color: #5a5a5a;
}

.shortcut-help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.shortcut-help-table th,
.shortcut-help-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #ececec;
    text-align: left;
    vertical-align: top;
}

.shortcut-help-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    background: #f7f7f7;
}

.shortcut-help-table kbd {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid #d1d1d1;
    background: #fff;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn {
    padding: 8px 16px;
    color: var(--bg-surface);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: opacity var(--transition-default);
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background: var(--accent-focus);
}

.btn-success {
    background: #2ecc71;
}

.btn-info {
    background: #3498db;
}

.btn-danger {
    background: var(--action-danger);
}

.btn-danger-dark {
    background: var(--action-danger-hover);
}

.btn-warning {
    background: #e67e22;
    color: var(--bg-surface);
}

.btn-warning:hover {
    background: #d35400;
}

.btn-warning-dark {
    background: var(--action-danger-hover);
    color: var(--bg-surface);
}

.btn-warning-dark:hover {
    background: #a93226;
}

.btn-outline {
    background: transparent;
    border: 1px solid #999;
    color: var(--text-hover);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
}
.btn-outline:hover {
    background: var(--bg-canvas);
    border-color: var(--text-dim);
}

.btn-template {
    background: #8e44ad;
    color: var(--bg-surface);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.btn-template:hover { background: #7d3c98; }
.btn-template:disabled { background: var(--border-hover); cursor: not-allowed; }

.template-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-input);
}

.template-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.template-status {
    font-size: 12px;
    color: var(--text-muted-alt);
}
.template-status.loaded {
    color: #27ae60;
    font-weight: 600;
}
.template-status.error {
    color: var(--action-danger);
}

.btn-apply {
    margin-top: 20px;
}

.btn-row {
    display: flex;
    gap: 10px;
}

.btn-row-top {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.export-section {
    margin-top: 20px;
    border-top: 1px solid #ddd;
    padding-top: 20px;
}

.yxmd-readiness-interface {
    min-height: 260px;
}

.yxmd-readiness-empty {
    color: var(--text-dim);
    font-size: 13px;
    padding: 12px 0;
}

.yxmd-readiness-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.yxmd-readiness-stat {
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    padding: 10px;
    background: var(--bg-surface-alt);
}

.yxmd-readiness-stat-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.yxmd-readiness-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-white-kw);
    line-height: 1.2;
}

.yxmd-readiness-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.yxmd-readiness-ux {
    border: 1px solid #d7e3f5;
    border-radius: var(--radius-md);
    background: #f4f8ff;
    padding: 10px 12px;
    margin-bottom: 10px;
}

.yxmd-readiness-ux-line {
    font-size: 12px;
    color: #2f3b54;
}

.yxmd-readiness-ux-label {
    font-weight: 600;
}

.yxmd-readiness-meta {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.yxmd-readiness-table-wrap {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.yxmd-readiness-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.yxmd-readiness-table th,
.yxmd-readiness-table td {
    border-bottom: 1px solid #f0f0f0;
    padding: 8px 10px;
    vertical-align: top;
    text-align: left;
}

.yxmd-readiness-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f6f6f8;
    color: var(--text-secondary);
    font-weight: 600;
}

.yxmd-readiness-table td:nth-child(1) {
    white-space: nowrap;
    width: 120px;
}

.yxmd-readiness-table td:nth-child(3) {
    white-space: nowrap;
    width: 110px;
}

.yxmd-readiness-table td:nth-child(5) {
    white-space: nowrap;
    width: 190px;
}

.yxmd-readiness-actions-cell .btn {
    padding: 6px 10px;
    margin-right: 6px;
}

.yxmd-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.yxmd-status-supported {
    background: #e8f7ee;
    color: #1f8a4c;
}

.yxmd-status-partial {
    background: #fff3d9;
    color: #9a6a00;
}

.yxmd-status-unsupported {
    background: #fde7e7;
    color: #b3261e;
}

.yxmd-manual-action {
    color: var(--text-dim);
    font-size: 12px;
}

.yxmd-recipe-inline-hint {
    margin-top: 6px;
    font-size: 11px;
    color: #8a5a00;
}

.yxmd-recipe-row td {
    background: #fcfcff;
    padding: 10px;
}

.yxmd-recipe-box {
    border: 1px solid #e7e7f2;
    background: #f7f8ff;
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.yxmd-recipe-title {
    font-size: 13px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 4px;
}

.yxmd-recipe-summary {
    font-size: 12px;
    color: #44546a;
    margin-bottom: 8px;
}

.yxmd-recipe-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5d6d86;
    margin-top: 8px;
    margin-bottom: 4px;
}

.yxmd-recipe-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.yxmd-recipe-chip {
    background: var(--bg-surface);
    border: 1px solid #d4dbed;
    border-radius: var(--radius-pill);
    padding: 3px 9px;
    font-size: 11px;
    color: #334155;
}

.yxmd-recipe-steps {
    margin: 4px 0 0 18px;
    padding: 0;
}

.yxmd-recipe-steps li {
    font-size: 12px;
    color: #364152;
    margin-bottom: 4px;
}

.yxmd-recipe-note {
    margin-top: 8px;
    font-size: 11px;
    color: #6b7280;
}

.export-heading {
    margin-bottom: 10px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
}

.form-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.form-help {
    font-size: 11px;
    color: var(--text-muted-alt);
    margin-top: 5px;
}


.u-mb-15 { margin-bottom: 15px; }
.u-mb-20 { margin-bottom: 20px; }
.u-mt-10 { margin-top: 10px; }
.u-mt-12 { margin-top: 12px; }
.u-mt-15 { margin-top: 15px; }
.u-mr-8 { margin-right: 8px; }
.u-fw-600 { font-weight: 600; }
.u-flex-1 { flex: 1; }
.u-flex-2 { flex: 2; }
.u-flex-gap30 { display: flex; gap: 30px; }
.u-flex-wrap-gap8 { display: flex; flex-wrap: wrap; gap: 8px; }
.u-flex-center-pointer { display: flex; align-items: center; cursor: pointer; }
.u-row-gap8 { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.u-grid-2-gap10-mb12 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }

.u-text-error { color: #e44; }
.u-muted-italic { color: var(--text-subtle); font-style: italic; }
.u-muted-13-mb10 { color: var(--text-dim); font-size: 13px; margin-bottom: 10px; }
.u-center-muted { text-align: center; color: var(--text-muted-alt); }
.u-note { margin-top: 15px; color: var(--text-dim); font-size: 12px; }
.u-help-12 { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.u-help-12-mt5 { font-size: 12px; color: var(--text-dim); margin-top: 5px; }
.u-placeholder { color: var(--text-subtle); font-size: 13px; text-align: center; }
.u-title-14 { font-size: 14px; margin-bottom: 10px; font-weight: 600; }
.u-title-13 { font-size: 13px; margin-bottom: 8px; font-weight: 600; }
.u-label-strong { display: block; margin-bottom: 5px; font-weight: 600; }
.u-label-14 { display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px; }

.u-input-plain { width: 100%; padding: 8px; border: 1px solid var(--border-input); border-radius: var(--radius-sm); }
.u-input { width: 100%; padding: 8px; border: 1px solid var(--border-input); border-radius: var(--radius-sm); font-size: 13px; }
.u-input-mb15 { width: 100%; padding: 8px; border: 1px solid var(--border-input); border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 15px; }
.u-input-sm { width: 100%; padding: 6px; border: 1px solid var(--border-input); border-radius: var(--radius-sm); font-size: 13px; }
.u-flex-input { flex: 1; padding: 8px; border: 1px solid var(--border-input); border-radius: 3px; font-size: 13px; }

.u-btn-neutral { margin-top: 10px; padding: 8px 15px; background: var(--bg-canvas); border: 1px solid var(--border-input); border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; }
.u-btn-danger-sm { padding: 8px; background: var(--action-danger); color: var(--bg-surface); border: none; border-radius: 3px; cursor: pointer; font-size: 12px; }
.u-btn-xs { font-size: 11px; padding: 2px 8px; }

.u-panel-scroll { border: 1px solid var(--border-input); border-radius: var(--radius-sm); padding: 15px; background: var(--bg-surface); max-height: 400px; overflow-y: auto; }
.u-table-compact { width: 100%; border-collapse: collapse; background: var(--bg-surface); font-size: 12px; }
.u-cell-border { padding: 8px; border: 1px solid var(--border-input); }
.u-cell-8 { padding: 8px; border-bottom: 1px solid #f0f0f0; }
.u-th-compact { text-align: left; padding: 4px 8px; }
.u-th-border { text-align: left; padding: 6px; border-bottom: 2px solid var(--border); }
.u-td-border { padding: 4px 6px; border-bottom: 1px solid var(--border); }

.text-input-editor {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    white-space: pre;
    resize: vertical;
}

.text-input-current-data {
    margin-top: 4px;
    color: var(--text-muted-alt);
    font-size: 12px;
}

.automapper-summary {
    background: #f0f8ff;
    padding: 12px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent-focus);
    margin-bottom: 15px;
}

.automapper-grid-header,
.automapper-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 15px;
    align-items: center;
    border-radius: var(--radius-sm);
}

.automapper-grid-header {
    margin-bottom: 10px;
    padding: 10px;
    background: var(--bg-primary);
    font-weight: 600;
    font-size: 13px;
}

.automapper-row {
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-input);
    margin-bottom: 8px;
}

.automapper-out-col {
    font-weight: 500;
}

.automapper-arrow {
    color: var(--text-dim);
    font-size: 18px;
}

.automapper-input-col {
    color: var(--text-white-kw);
}

.automapper-input-col--unmatched {
    color: var(--text-subtle);
    font-style: italic;
}

.automapper-match {
    display: flex;
    align-items: center;
    gap: 5px;
}

.automapper-match-icon {
    font-size: 16px;
}

.automapper-match-text {
    font-size: 11px;
    font-weight: 500;
}

.automapper-match--exact {
    color: #2ecc71;
}

.automapper-match--partial {
    color: #f39c12;
}

.automapper-match--fuzzy {
    color: #e67e22;
}

.automapper-match--unmatched {
    color: var(--text-disabled);
}

.automapper-unmapped {
    margin-top: 20px;
    padding: 12px;
    background: #e8f5e9;
    border-radius: var(--radius-sm);
    border-left: 4px solid #4caf50;
}

.automapper-unmapped-help {
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-dim);
}

.automapper-unmapped-list {
    margin-top: 8px;
    font-size: 12px;
}

.automapper-unmapped-chip {
    display: inline-block;
    padding: 4px 8px;
    background: var(--bg-surface);
    border-radius: 3px;
    margin-right: 5px;
    margin-bottom: 5px;
}

.output-preview-panel {
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    padding: 20px;
    background: #f9f9f9;
}

.output-preview-panel--rejected {
    background: #fff5f5;
}

.output-rejected-title {
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--action-danger);
}

.output-import-path {
    font-size: 12px;
    color: #4a6f2a;
    margin-bottom: 10px;
}

.output-column-chip {
    padding: 6px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.output-column-chip--error {
    background: #ffe6e6;
}

.output-table-head {
    padding: 8px;
    border: 1px solid var(--border-input);
    background: var(--bg-primary);
    text-align: left;
}

.output-table-head--error {
    background: #ffe6e6;
}

.log-output {
    max-height: 500px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 12px;
    background: var(--bg-primary);
    padding: 15px;
    border-radius: var(--radius-sm);
    line-height: 1.6;
}

.hidden {
    display: none;
}


.context-menu {
    position: fixed;
    z-index: 10001;
    background: var(--bg-surface);
    border: 1px solid #ddd;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 4px 0;
    min-width: 160px;
}

.context-menu-item {
    padding: 7px 14px;
    font-size: 12px;
    color: var(--text-white-kw);
    cursor: pointer;
}

.context-menu-item:hover {
    background: var(--bg-surface-info);
}

.context-menu-item.danger {
    color: #c43030;
}

.context-menu-item.danger:hover {
    background: var(--bg-error-muted);
}

.context-menu-item.disabled {
    color: var(--text-very-dim);
    cursor: default;
}

.context-menu-item.disabled:hover {
    background: transparent;
}

.context-menu-divider {
    height: 1px;
    background: var(--bg-deep);
    margin: 4px 0;
}


#toast-container {
    position: fixed;
    bottom: 56px;
    right: 12px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: auto;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-info {
    background: #2e6ec4;
}

.toast-success {
    background: #1a8a3f;
}

.toast-warn,
.toast-warning {
    background: #b47a1a;
}

.toast-error {
    background: #c43030;
}


.select-col-row.drag-over {
    border-top: 2px solid var(--accent-focus);
}

.drag-handle:active {
    cursor: grabbing;
}


.block.multi-selected .block-icon-area {
    box-shadow: 0 0 0 3px rgba(59,130,246,0.4), 0 2px 8px rgba(0,0,0,0.15);
}

.lasso-rect {
    position: absolute;
    border: 1px dashed #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    pointer-events: none;
    z-index: 5;
}


td.cell-null {
    color: var(--text-disabled);
    font-style: italic;
}

td.cell-number {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #1a7f37;
}

td.cell-bool-true {
    color: #1a7f37;
    font-weight: 600;
}

td.cell-bool-false {
    color: #cf222e;
    font-weight: 600;
}


.formula-no-input {
    color: #e44;
    padding: 8px 0;
}

.formula-expr-row {
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg-surface-alt);
}

.formula-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.formula-row-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-hover);
}

.formula-remove-row {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-subtle);
    padding: 0 4px;
    line-height: 1;
}

.formula-remove-row:hover {
    color: #e44;
}

.formula-field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 3px;
    margin-top: 6px;
}

.formula-output-col {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.formula-expr-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
    resize: vertical;
    min-height: 38px;
}

.formula-expr-input:focus,
.formula-output-col:focus {
    outline: none;
    border-color: #b5302a;
    box-shadow: 0 0 0 2px rgba(181, 48, 42, 0.15);
}

.formula-add-row {
    margin-bottom: 12px;
    font-size: 13px;
}

.formula-columns-ref {
    margin-bottom: 12px;
}

.formula-section-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
}

.formula-col-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
}

.formula-col-badge {
    display: inline-block;
    padding: 3px 8px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-default), border-color var(--transition-default);
}

.formula-col-badge:hover {
    background: var(--bg-hover-alt);
    border-color: #99c;
}


.formula-ac-dropdown {
    position: absolute;
    z-index: 1000;
    background: var(--bg, #fff);
    border: 1px solid var(--border, #d0d0d0);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
}

.formula-ac-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    cursor: pointer;
    gap: 8px;
}

.formula-ac-item:hover,
.formula-ac-selected {
    background: var(--hover, #f0f4ff);
}

.formula-ac-label {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-weight: 600;
    white-space: nowrap;
}

.formula-ac-detail {
    color: var(--text-secondary, #888);
    font-size: 11px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.formula-syntax-ref {
    margin-top: 8px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.formula-syntax-ref summary {
    padding: 8px 10px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-hover);
    user-select: none;
}

.formula-syntax-ref summary:hover {
    color: var(--text-white-kw);
}

.formula-syntax-body {
    padding: 8px 12px 12px;
    border-top: 1px solid var(--border-input);
    background: var(--bg-surface-alt);
    line-height: 1.6;
}

.formula-syntax-body p {
    margin-bottom: 6px;
}

.formula-syntax-body code {
    background: var(--bg-deep);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
}


/* ── Touch interaction styles ── */

.touch-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.85;
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
}

.block.long-press-active {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.canvas.touch-panning {
    cursor: move;
}

/* ── Responsive safeguards ── */

@media (max-width: 980px) {
    header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .header-center {
        order: 3;
        flex-basis: 100%;
    }

    .header-actions {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .workspace { flex-direction: column; }
    .toolbox {
        width: 100%;
        max-height: 168px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 8px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transition: max-height 0.2s ease, padding 0.2s ease;
    }
    .toolbox.toolbox-collapsed {
        max-height: 0;
        padding: 0 8px;
        border-bottom: none;
        overflow: hidden;
    }
    .toolbox-toggle {
        display: flex;
    }
    .tool-group-items:not(.collapsed) {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .tool-item {
        flex: 1 1 148px;
        min-width: 0;
        margin-bottom: 0;
        font-size: 11px;
    }
    header {
        padding: 10px 12px;
        gap: 8px;
    }
    header h1 {
        font-size: 15px;
    }
    .header-center {
        display: none;
    }
    .header-actions,
    .header-primary-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .header-actions .flow-btn,
    .zoom-btn,
    .config-panel-close,
    .template-gallery-close,
    .close {
        min-height: 44px;
        min-width: 44px;
    }
    .header-overflow-menu {
        position: fixed;
        top: 76px;
        right: 12px;
        left: 12px;
        width: auto;
    }
    .config-panel,
    .config-panel.open,
    .config-panel.open.wide {
        width: 100% !important;
        max-width: 100%;
    }
    .config-panel-header,
    .config-panel-body,
    .config-panel-footer,
    .config-panel.wide .config-panel-header,
    .config-panel.wide .config-panel-body,
    .config-panel.wide .config-panel-footer {
        min-width: 0;
        width: 100%;
    }
    .config-panel {
        max-height: 60vh;
        border-left: none;
        border-top: 1px solid var(--border);
        -webkit-overflow-scrolling: touch;
    }
    .canvas {
        padding: 10px;
    }
    .modal-content {
        margin: 5% auto;
        padding: 20px;
        width: min(400px, calc(100vw - 24px));
        max-height: 90vh;
    }
    .modal-content.large {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .toolbox {
        max-height: 184px;
    }
    .header-primary-actions {
        width: 100%;
    }
    .header-primary-actions .flow-btn,
    .header-overflow .flow-btn {
        flex: 1 1 calc(50% - 8px);
    }
    .modal-content {
        margin: 2% auto;
        padding: 16px;
        border-radius: var(--radius-md);
    }
    .modal-content.large {
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.svg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.cursor-grabbing { cursor: grabbing; }
.cursor-move { cursor: move; }
.drag-opacity { opacity: 0.4; }
.visibility-hidden { visibility: hidden; }
.icon-18 { width: 18px; height: 18px; }
.u-text-center { text-align: center; }
.u-text-xs-muted { font-size: 12px; color: var(--text-dim); }

.drag-list-item {
    padding: 6px 10px;
    margin-bottom: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: grab;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-row-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}
