#variation-builder-app {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    font-family: 'Inter', sans-serif;
    max-width: 900px;
    margin: 0 auto;
}

.vb-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

/* Instructions Card */
.tool-instructions {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    margin-top: 2rem;
    font-family: 'Inter', sans-serif;
}

.tool-instructions h3 {
    margin-top: 0;
    color: #1e293b;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.tool-instructions ul {
    padding-left: 1.5rem;
    color: #475569;
}

.tool-instructions li {
    margin-bottom: 0.5rem;
}


.controls-area {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.x-row-config {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.x-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.x-tag {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.x-tag input {
    background: transparent;
    border: none;
    width: 60px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.x-tag button {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    margin-left: 4px;
}

.x-tag button:hover {
    color: #ef4444;
}

.add-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.add-btn:hover {
    background: #2563eb;
}


/* PREVIEW GRID */
.preview-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow-x: auto;
}

.row {
    display: flex;
    align-items: center;
}

.cell {
    padding: 0.5rem;
}

.label-cell {
    width: 80px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.label-cell input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px;
    text-align: center;
}

.sign-track {
    display: flex;
    align-items: center;
    flex: 1;
}

.sign-node {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    background: white;
}

.sign-node:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.sign-interval {
    flex: 1;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    font-weight: bold;
}

.sign-interval:hover {
    color: #3b82f6;
}

.var-track {
    flex: 1;
    display: flex;
    align-items: stretch;
    /* Stretch to fill height */
    min-height: 80px;
}

.var-node {
    width: 60px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center input vertically */
    align-items: center;
    padding: 0.25rem;
}

.var-input {
    width: 100%;
    text-align: center;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Split node for double bar */
.split-node {
    flex-direction: row;
    padding: 0;
    overflow: hidden;
}

.split-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.split-divider {
    width: 1px;
    background: #e2e8f0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #94a3b8;
}

.var-spacer {
    flex: 1;
}


/* OUTPUT AREA */
.output-area {
    margin-top: 2rem;
}

.code-header {
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#latex-output {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    font-family: monospace;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    background: #f8fafc;
}

.btn-copy {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.btn-copy:hover {
    background: #2563eb;
}

.btn-overleaf {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.btn-overleaf:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.add-mini-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #10b981;
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-mini-btn:hover {
    background: #059669;
}

/* Simulated Preview Styles */
.sim-table {
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 1px solid black;
    font-family: 'Times New Roman', serif;
    background: white;
    /* Ideally simulate paper */
}

.sim-row {
    display: flex;
    border-bottom: 1px solid black;
}

.sim-row:last-child {
    border-bottom: none;
}

.sim-cell {
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid black;
}

.sim-label {
    width: 80px;
    /* Matches label-cell width broadly */
    flex-shrink: 0;
}

.sim-track-wrapper {
    flex: 1;
    display: flex;
    align-items: stretch;
}

.sim-item {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sim-node {
    width: 40px;
    /* Fixed width for nodes (x values) */
    position: relative;
    /* For positioning vertical bars if needed */
}

.sim-interval {
    flex: 1;
    /* Flexible space */
}

/* Specifics for Sign Row */
.d-bar {
    height: 100%;
    width: 4px;
    border-left: 1px solid black;
    border-right: 1px solid black;
}

/* Specifics for Variation Row */
.sim-var-track {
    position: relative;
    /* Drawing canvas for arrows */
}

.sim-var-node {
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Default center */
    /* Taller row for vars */
    height: 120px;
}

.pos-high {
    justify-content: flex-start;
    padding-top: 2px;
}

.pos-low {
    justify-content: flex-end;
    padding-bottom: 2px;
}

.sim-var-interval {
    height: 120px;
    position: relative;
}

/* Split Node (Forbidden value in Var row) */
.split-node {
    flex-direction: row;
    align-items: stretch;
    width: 60px;
    /* Slightly wider */
}

.split-part {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.split-bar {
    width: 4px;
    border-left: 1px solid black;
    border-right: 1px solid black;
    background: url('data:image/svg+xml;utf8,<svg ... pattern for hatch ... ></svg>');
    /* Optional hatching */
}

.ghost {
    visibility: hidden;
}